标签: account-management

在Windows中安全地存储密码

目前,我将我的用户名和密码存储在SQL Server CE数据库中.

我想使用一些Windows API来安全地存储我的用户密码,这样机器上运行的其他应用程序就无法读取它们.

我支持Windows 7,因此我无法使用密码保险库

我已经尝试使用CredWriteCredRead API,基于此处提供的示例.

但是,当我成功设法存储和恢复我的密码时,我也成功地设法使用完全不同的应用程序恢复它们.这意味着我唯一的安全就是我正在使用的密钥.

还有其他可行的解决方案吗?

似乎任何使用Windows安全帐户管理器的人都不会这样做.

c# winapi password-protection account-management passwordvault

7
推荐指数
1
解决办法
3134
查看次数

使用System.DirectoryServices.AccountManagement时的DirectoryServicesCOMException

我正在尝试使用System.DirectoryServices.AccountManagment确定用户是否是给定组的成员.

  • 我在64位系统上的SharePoint 2007中的SharePoint WebPart中执行此操作.
  • 项目目标是.NET 3.5
  • 在web.config中启用了模拟.
  • 有问题的IIS站点使用IIS应用程序池,并将域用户配置为标识.

我可以实例化PrincipalContext如下:

PrincipalContext pc = new PrincipalContext(ContextType.Domain)

接下来,我试着抓住一个校长:

using (PrincipalContext pc = new PrincipalContext(ContextType.Domain))
{
   GroupPrincipal group = GroupPrincipal.FindByIdentity(pc, "MYDOMAIN\somegroup");
   // snip: exception thrown by line above.
}
Run Code Online (Sandbox Code Playgroud)

以上和UserPrincipal.FindByIdentity用户SAM都抛出DirectoryServicesCOMException:"登录失败:未知用户名或密码错误"

我已经尝试将完整的SAMAccountName传递给FindByIdentity(以MYDOMAIN \用户名的形式)或只是用户名而行为没有变化.我已尝试使用其他凭据HostingEnvironment.ImpersonateSPSecurity.RunWithElevatedPrivileges方法执行代码,并且也会遇到相同的结果.

我还尝试使用域名实例化我的上下文:

Principal Context pc = new PrincipalContext(ContextType.Domain, "MYDOMAIN");

这引发了PrincipalServerDownException:"无法联系到服务器."

我正在研究一台相当硬化的服务器.我没有锁定系统,所以我不确定它到底做了什么.如果我需要为我的池标识用户或域安全策略分配凭据以使这些凭据有效,我可以相应地配置域.是否有任何设置会阻止我的代码运行?我在代码本身中遗漏了什么吗?这在SharePoint网站中是不可能的吗?

编辑:经过进一步测试,我的代码在面向.NET 4.0的控制台应用程序中测试时正常运行.我针对不同的框架,因为在针对.NET 3.5出于某种原因我没有在控制台应用程序中使用AccountManagement.

using (PrincipalContext pc = new PrincipalContext(ContextType.Domain))
using (UserPrincipal adUser = UserPrincipal.FindByIdentity(pc, "MYDOMAIN\joe.user"))
using (GroupPrincipal adGroup …
Run Code Online (Sandbox Code Playgroud)

c# sharepoint-2007 account-management c#-3.0

6
推荐指数
1
解决办法
4528
查看次数

PreferenceScreen - <intent ... /> - 异常 - FLAG_ACTIVITY_NEW_TASK

我是android开发的新手.

该项目是关于使用AbstractThreadedSyncAdapter实现AbstractAccountAuthenticator,以将服务器上的某些数据与内容提供程序同步.

我做了一切,添加帐户和同步都运行没有任何问题.

现在我尝试添加一个Preference-Screen,就像在android参考中一样建议(搜索AbstractAccountAuthenticator,它在那里解释)来自xml,如下所示:

autenticator.xml:

<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
    android:accountType="typeOfAuthenticator"
    android:icon="@drawable/icon"
    android:smallIcon="@drawable/miniIcon"
    android:label="@string/label"
    android:accountPreferences="@xml/account_preferences"
 />
Run Code Online (Sandbox Code Playgroud)

Preference-Screen-xml看起来像这样:

account_preferences.xml:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
 <PreferenceCategory android:title="@string/pref_cat_general">
  <PreferenceScreen android:key="@string/pref_cat_scr_keygen" android:title="@string/pref_cat_scr_keygen_title" android:summary="@string/pref_cat_scr_keygen_summary">
   <intent android:action="android.intent.action.VIEW" android:targetPackage="com.android.clean" android:targetClass="com.android.clean.KeygenAct" />
  </PreferenceScreen>
 </PreferenceCategory>
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)

屏幕应该是它应该如何,但这就是问题:当我点击PreferenceScreen意图导致系统崩溃(在模拟器和我的HTC-Desire中).

Logcat说:

ERROR/AndroidRuntime(18754):android.util.AndroidRuntimeException:从Activity上下文外部调用startActivity()需要FLAG_ACTIVITY_NEW_TASK标志.这真的是你想要的吗?

(整个Logcat on pastebin)

这里是清单的一部分,其中定义了活动:

<activity android:name=".KeygenAct">
    <intent-filter>
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

整个测试代码(这是我找到问题的基本要点的项目)是在googlecode(http://code.google.com/p/cleanproject/source/browse/)上找到(Eclipse-Project)

谢谢你的帮助,Esentian

ps:keygen不是密钥生成器,它意味着更多key_general.有点不好意思;)

xml android exception account-management preferencescreen

6
推荐指数
1
解决办法
6645
查看次数

无法在ASP.NET VB站点中加载System.DirectoryServices.AccountManagement

我一直在按照Microsoft的本指南向现有的ASP.NET网站添加Active Directory功能:http://support.microsoft.com/kb/326340.这是一个漫长的过程,但我现在坚持的是无法访问AccountManagement类以使用某些功能,例如"GetGroup()".

我可以很好地访问DirectoryServices,但不能访问帐户管理.当我使用以下代码来测试引用时:

Response.Write(System.DirectoryServices.AccountManagement.Principal.GetGroups())
Run Code Online (Sandbox Code Playgroud)

我收到此错误:BC30456:'AccountManagement'不是'DirectoryServices'的成员.

我已经将此程序集标记添加到web.config页面:

<add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
Run Code Online (Sandbox Code Playgroud)

我也导入两个名称空间:

<%@ Import Namespace="System.DirectoryServices" %>
<%@ Import Namespace="System.DirectoryServices.AccountManagement" %>
Run Code Online (Sandbox Code Playgroud)

这是我在错误页面上显示的版本信息:

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.34237

我正在VS 2010中编辑这个网站.我错过了什么,如何在此处添加AccountManagement?我没有正确导入它,或者在某处我可以查看是否有丢失的.dll?

.net vb.net asp.net directoryservices account-management

6
推荐指数
2
解决办法
1万
查看次数

GroupPrincipal.Members.Remove()不适用于大型AD组

我正在使用System.DirectoryServices.AccountManagement命名空间类来管理多个组的成员身份.这些群体控制着我们的印刷会计系统的人口,其中一些非常庞大.我遇到了从这些大型组中删除任何用户的问题.我有一个测试程序来说明问题.请注意,我正在测试的组不是嵌套的,但user.IsMemberOf()似乎也有同样的问题,而GetAuthorizationGroups()正确显示用户所属的组.有问题的小组有大约81,000名成员,因为Remove()不起作用,所以它应该超过它应该有的,并且通常大约是65K左右.

我有兴趣听到有其他人遇到过这个问题并已经解决了.我有一个与微软打开的案例,但由于呼叫中心的时间差大约为17小时,因此呼叫转向很慢,因此他们在我离开家之前大约一个小时才到达工作岗位.

using (var context = new PrincipalContext( ContextType.Domain ))
{
    using (var group = GroupPrincipal.FindByIdentity( context, groupName ))
    {
        using (var user = UserPrincipal.FindByIdentity( context, userName ))
        {
            if (user != null)
            {
                var isMember = user.GetAuthorizationGroups()
                                   .Any( g => g.DistinguishedName == group.DistinguishedName );
                Console.WriteLine( "1: check for membership returns: {0}", isMember );
                if (group.Members.Remove( user ))
                {
                    Console.WriteLine( "user removed successfully" );
                    group.Save();
                }
                else
                {
                    // do save in case Remove() is lying to me …
Run Code Online (Sandbox Code Playgroud)

.net c# active-directory account-management

5
推荐指数
1
解决办法
3950
查看次数

StackExchange站点如何关联用户帐户和OpenID登录?

我喜欢StackExhchange/StackOverflow集成OpenID的方法.

据我了解,这个过程是这样的:

  • 如果用户使用OpenID提供商(即Google)注册,则StackOverflow(或类似网站)会为该用户创建一个帐户,并将OpenID与该帐户相关联.
  • 现有用户可以将多个OpenID帐户与他/她的StackExchange帐户相关联.

我很乐意模仿这种行为,因为我还没有在其他网站上看到它几乎用户友好.

我知道StackExchange是基于ASP.NET MVC构建的,但我不确定它是否使用标准的ASP.NET凭据模型,然后将OpenID提供程序添加到单独的数据库表中或者是什么.

所以,我的问题是:

  • StackExchange如何创建这些帐户?他们是否在标准ASP.NET MVC提供程序中创建用户,然后关联该ID,或者是否有单独的进程?
  • StackExchange如何允许其他OpenID提供程序帐户与现有帐户相关联?

在此先感谢您提供任何帮助!

openid asp.net-mvc account-management user-accounts openid-provider

5
推荐指数
1
解决办法
660
查看次数

UserPrincipal.FindByIdentity坚持"服务器上没有这样的对象."

我目前的目标是使用程序集中的实用程序为基于域安全组的ASP.NET应用程序实现只读角色提供System.DirectoryServices.AccountManagement程序.我有以下代码在我的开发域中正常工作,但在部署环境中失败:

Using myContext As New PrincipalContext(ContextType.Domain, Nothing, "DC=My,DC=Controller", accountName, accountPassword)
    Try
        Dim p As UserPrincipal = UserPrincipal.FindByIdentity(myContext, IdentityType.SamAccountName, userName)
        Dim groups = p.GetAuthorizationGroups()
        For Each g In groups
            Debug.WriteLine("Found security group: " & g.DisplayName & vbNewLine)
        Next
    Catch ex As Exception
        Debug.WriteLine("Encountered an exception: " & vbNewLine & ex.ToString())
    End Try
End Using
Run Code Online (Sandbox Code Playgroud)

异常堆栈跟踪返回如下:

    System.DirectoryServices.AccountManagement.PrincipalOperationException: There is no such object on the server.
     ---> System.DirectoryServices.DirectoryServicesCOMException (0x80072030): There is no such object on the server.
       at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
       at …

.net vb.net active-directory account-management .net-3.5

5
推荐指数
1
解决办法
2万
查看次数

用户名通常受限制的关键字的任何来源?

我正在开发一项网络服务,需要限制用户注册某些用户名,例如admin,root等.

我知道这是每个人在开发新服务时都会遇到的常见问题,因此我认为应该有一个数据库或至少一些网站常用禁止用户名的例子,但是在Google上找不到它.我想我不是用正确的关键字搜索它.

任何人都可以指向这个资源吗?

account-management user-accounts

5
推荐指数
1
解决办法
1337
查看次数

COMException未知错误(0x80005000) - DirectoryServices

我在我的一个应用程序上遇到错误,每个月发生几次,但本周发生了两次.当这种情况发生时,第一个用户加载应用程序并开始工作时,它总是第一件事(Web应用程序,3-4个内部用户)错误源于这个非常简单的方法,一旦失败,它将无法工作,直到我重启应用程序池.现在,我也以其他方式查询AD,但这是用户在早上开始工作时调用的第一个AD相关方法.

public DomainUser GetDomainUser(string userLoginName)
    {
        using (PrincipalContext context = new PrincipalContext(ContextType.Domain, this.DomainName))
        {
            using (UserPrincipal user = UserPrincipal.FindByIdentity(context, userLoginName))
            {
                // If user is null, the result is not a UserPrinciple
                if (user != null)
                {
                    string firstName = user.GivenName;
                    string middleName = user.MiddleName;
                    string lastName = user.Surname;
                    int empId = Convert.ToInt32(user.EmployeeId);
                    string emailAddr = user.EmailAddress;
                    string userName = user.SamAccountName;
                    DateTime? accountExp = user.AccountExpirationDate;

                    return new DomainUser
                    {
                        FirstName = firstName,
                        MiddleName = middleName,
                        LastName = lastName,
                        EmployeeId = …
Run Code Online (Sandbox Code Playgroud)

asp.net directoryservices active-directory account-management

5
推荐指数
1
解决办法
4421
查看次数

通过employeeID获取UserPrincipal

我已经实现了System.DirectoryServices.AccountManagement用于身份验证到我的webapps查找用户(UserPrincipal)byidentity给定的用户名.但是,我有几种情况需要获得只有employeeID的AD帐户.在AccountManagement中给定一个employeeID是否有一种获得UserPrincipal(甚至只是sAMAccountName)的好方法?

我目前正在努力通过用户名抓取用户:

PrincipalContext adAuth = new PrincipalContext(ContextType.Domain, Environment.UserDomainName);

//get user
UserPrincipal usr = UserPrincipal.FindByIdentity(adAuth, username);
Run Code Online (Sandbox Code Playgroud)

我一直在寻找,似乎无法找到答案,以确认这是否可以做到.如果我不能使用AccountManagement,那么获得sAMAccountName给employeeID的最佳方法是什么?

c# account-management asp.net-4.0

5
推荐指数
1
解决办法
5964
查看次数