标签: account-management

社交网络(Facebook,Twitter等)用户帐户集成(重复方案)

因此,关于如何将各种个人社交网络身份验证/注册集成到现有用户帐户中,肯定有很多教程.但我似乎无法找到很多信息的情况是用户是否使用不同的社交网络凭据登录您的帐户.例如:

场景#1
用户使用站点的身份验证在站点上注册.
用户然后使用Facebook Connect在现场登录/注册.
用户然后使用Twitter在网站上登录/注册.

如何将所有这些整合到一个帐户中?

显然,一旦用户注册,他们就可以在帐户设置页面中添加其他社交网络关联.但我更担心的是,如果他们通过其他社交网络注册而不记得他们已经设置好了.

我的一般想法是试图找出一种方法来使用"用户名"或电子邮件来尝试猜测并向用户呈现在那里组合帐户的方法.

有人有什么想法?

twitter facebook account-management user-accounts

14
推荐指数
1
解决办法
3437
查看次数

System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity的奇怪问题

我们正在编写一个允许用户通过Intranet上的Web应用程序更改其帐户密码的系统.

起初,一切似乎都在顺利进行.在开发期间,我们的测试帐户的密码可以毫无问题地更改.

然而,当我们制作系统时,我们开始遇到问题.以下是症状:

  1. 一开始,一切都很好.用户可以更改其密码.
  2. 在某些时候,UserPrincipal.FindByIdentity中出现以下错误:"System.Runtime.InteropServices.COMException:身份验证机制未知."
  3. 从那时起,尝试通过Web应用程序更改密码会导致错误:"System.Runtime.InteropServices.COMException:服务器无法运行."
  4. 如果我手动回收应用程序池,一切似乎都会自行解决,直到更多错误开始发生...即,该过程在第1阶段重新开始.

这是相关的代码片段:


    private static PrincipalContext CreateManagementContext() {
        return new PrincipalContext(
            ContextType.Domain, 
            ActiveDirectoryDomain, 
            ActiveDirectoryManagementAccountName,
            ActiveDirectoryManagementAccountPassword);
    }


    private static void ChangeActiveDirectoryPasword(string username, string password) {
        if (username == null) throw new ArgumentNullException("username");
        if (password == null) throw new ArgumentNullException("password");

        using (var context = CreateManagementContext())
        using (var user = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, username)) {
            user.SetPassword(password);
        }
    }
Run Code Online (Sandbox Code Playgroud)

关于为什么会发生这种情况的任何线索?谷歌搜索没有提供任何真正有用的信息,MSDN上的文档也没有.

directoryservices memory-leaks ldap active-directory account-management

13
推荐指数
1
解决办法
5581
查看次数

帐户验证:每人只能使用一个帐户

在我的社区中,每个用户应该只有一个帐户.

所以我需要一个解决方案来验证特定帐户是用户拥有的唯一帐户.目前,我使用电子邮件验证.但我真的不需要用户的电子邮件地址.我只是试图阻止每个人的多个帐户.

但是,这当然不起作用.无论如何,人们创建临时电子邮件地址或拥有多个地址.因此,他们使用不同的电子邮件地址注册,因此他们获得了多个帐户 - 这是不允许的.

所以我需要一个比(易于规避)电子邮件验证更好的解决方案.顺便说一下,我不想使用OpenID,Facebook Connect等.

要求:

  • 验证方法必须可供所有用户访问
  • 用户应该没有任何费用(至少1美元)
  • 验证必须安全(比电子邮件方法更安全)
  • 不应要求用户公开过多的私人信息
  • ...

你有好方法的想法吗?非常感谢你提前!

附加信息:

我的社区是一个浏览器游戏,即足球经理游戏.使多个帐户具有吸引力的是用户可以交易他们的玩家.因此,如果您有两个账户,您可以购买价格过高的弱势玩家,这是"真正的"买家无法支付的.因此,当"第二个帐户"变得贫穷时,您的"第一个帐户"会获得巨额资金.但你不必关心:只需创建另一个帐户,使第一个帐户更丰富.

verification account-management user-accounts

12
推荐指数
2
解决办法
3443
查看次数

如何向MVC应用程序公开内置安全性和用户管理?

我在IIS6上建立了一个MVC网站.我使用内置的ASP.NET Security而不使用Membership,就像在模板解决方案中实现它一样.很容易保护控制器或操作,但现在我需要将用户管理公开给登录到站点的管理员.我知道内置的ASP控件不是"最佳实践",而且是一种可以开始工作的狗.那么通过ASP.NET MVC应用程序提供用户管理的最佳实践是什么?

我考虑使用实体框架并将其连接到无数的存储过程.但这似乎很尴尬.我看到AccountMembershipService和FormsAuthenticationService的选项.这就是现有项目帐户控制器使用的内容.但是,我也不喜欢.

我不禁想到这应该已经从项目模板中出现了.这是任何网站的基本部分,你获得了15%,为什么不给其他人?

vb.net security asp.net-mvc account-management

9
推荐指数
1
解决办法
1550
查看次数

如何找到未使用PrincipalSearcher设置属性的UserPrincipal?

我正在尝试在未设置属性的AD LDS(ADAM)实例中搜索用户,例如,"company"属性未设置为ADAM存储(或AD)中的值.

当我使用PrincipalSearcherUserPrincipal定义AdvancedSearchFilters对象的自定义和自定义时,我收到错误:

An unhandled exception of type 'System.ArgumentException' occurred in System.DirectoryServices.dll

Additional information: The (&(objectClass=user)(!(company=))) search filter is invalid.
Run Code Online (Sandbox Code Playgroud)

这是我的示例代码:

using System;
using System.DirectoryServices.AccountManagement;
using System.Security.Permissions;
using System.Linq;

namespace AdamDump
{
    class Program
    {
        static void Main(string[] args)
        {
            PrincipalContext context = new PrincipalContext(ContextType.ApplicationDirectory, "MyAdamInstance:50000", "OU=Adam Users,dc=apps01,dc=mydomain", "queryaccount", "password");        

            // initialize a Query By Example
            using (MyUserPrincipal myUserPrincipal = new MyUserPrincipal(context))
            {
                myUserPrincipal.MyAdvancedFilters.WhereCompanyNotSet();

                PrincipalSearchResult<Principal> principals = null;

                // do the search...
                using (PrincipalSearcher …
Run Code Online (Sandbox Code Playgroud)

.net c# adam active-directory account-management

9
推荐指数
1
解决办法
6104
查看次数

无法检索有关域的信息(1355)

这是我的代码示例

var domainContext = new PrincipalContext(ContextType.Domain, "domain_server_ip",  
            "domain_admin_username", "domain_admin_password");
var group = GroupPrincipal.FindByIdentity(domainContext, "mygroup");
var users = group.Members.Where(member => names.Contains(member.Name))
            .ToList();
users.ForEach(u => group.Members.Remove(u));
group.Save(domainContext); // <-- Here I get the error
Run Code Online (Sandbox Code Playgroud)

如果我尝试获取用户组,则会出现相同的错误

var user = UserPrincipal.FindByIdentity(domainContext, "username");
var gps = user.GetGroups(domainContext).ToList(); // <-- Here I get the error
Run Code Online (Sandbox Code Playgroud)

我尝试ContextOptions.SimpleBind连接使用,但没有任何改变.
我也尝试过连接设置容器名称,但是没有任何改变.

请注意,我能够检索该组及其成员......所以我不明白为什么我无法保存组或读取用户组.

c# active-directory account-management

9
推荐指数
1
解决办法
3730
查看次数

扩展UserPrincipal; FindByIdentity()失败

扩展UserPrincipal以利用其内置属性...当我们重载FindByIdentity()方法时遇到问题.

来自Microsoft的示例http://msdn.microsoft.com/en-us/library/bb384372%28VS.90%29.aspx(为简洁起见,不包括部分):

[DirectoryRdnPrefix("CN")]
[DirectoryObjectClass("inetOrgPerson")]
public class InetOrgPerson : UserPrincipal {

   // Implement the overloaded search method FindByIdentity
   public static new InetOrgPerson FindByIdentity(PrincipalContext context, 
                                                  string identityValue) {
       return (InetOrgPerson)FindByIdentityWithType(context,
                                                    typeof(InetOrgPerson),
                                                    identityValue);
   }

   // Implement the overloaded search method FindByIdentity
   public static new InetOrgPerson FindByIdentity(PrincipalContext context, 
                                                  IdentityType identityType, 
                                                  string identityValue) {
       return (InetOrgPerson)FindByIdentityWithType(context, 
                                                    typeof(InetOrgPerson), 
                                                    identityType,
                                                    identityValue);
   } 
}
Run Code Online (Sandbox Code Playgroud)

如果我从MSDN示例中获取确切的代码并将其粘贴到我的应用程序中,它就不起作用.调用InetOrgPerson.FindByIdentity()返回null,如下:

if (null == InetOrgPerson.FindByIdentity(principalContext, UserName)) {
     throw new Exception("bah");
}
Run Code Online (Sandbox Code Playgroud)

实际上,从内部InetOrgPerson.FindByIdentity()调用FindByIdentityWithType()返回null,如下: …

c# directoryservices active-directory account-management userprincipal

8
推荐指数
1
解决办法
5701
查看次数

从Active Directory中获取已启用的帐户

System.DirectoryServices.AccountManagement.dll用来处理Active Directory以获取"域用户"组中的所有用户.

这将返回域中的所有用户,但我需要获取已启用的用户.

以下是一些示例代码:

List<string> users = new List<string>();

PrincipalContext pcContext = GetPrincipalContext();

GroupPrincipal grp = GroupPrincipal.FindByIdentity(pcContext,
                               IdentityType.Name,
                               "Domain Users");

foreach (Principal user in grp.GetMembers(true).OfType<UserPrincipal>())
{
    if (user.Enabled != false)
    {
        users.Add(user.Name);
    }
}
Run Code Online (Sandbox Code Playgroud)

其他组工作正常,但当该组是"域用户"时,该Enabled属性的值false适用于所有用户.这使得无法在不对每个用户进行进一步查询的情况下区分启用和禁用用户.

c# directoryservices active-directory account-management

8
推荐指数
1
解决办法
5188
查看次数

使用PrincipalSearcher搜索多个用户

是否可以使用单个PrincipalSearcher调用搜索多个用户名.也许通过提供所请求的用户名的"OR"作为过滤器标准?

directoryservices active-directory account-management

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

在UserPrincipal上更新名称字段

当我尝试更新UserPrincipal(Principal,真的)上的Name字段(对应于CN)时,我在调用UserPrincipal.Save()时收到错误"服务器不愿意处理请求".

我已经检查过以确保同一个OU中没有其他对象具有相同的名称(CN).

我正在运行的PrincipalContext是域根(不完全在用户帐户所在的OU级别).

这个错误可能有什么原因?是否可能与安全策略相关(即使我能够更新所有其他字段)?

using (var context = new PrincipalContext(ContextType.Domain, ConfigurationManager.AppSettings["domain"], ConfigurationManager.AppSettings["rootDN"], ContextOptions.Negotiate, ConfigurationManager.AppSettings["username"], ConfigurationManager.AppSettings["password"])) {
    var user = UserPrincipal.FindByIdentity(context, IdentityType.Sid, "..."); // SID abbreviated

    user.Name = "Name, Test";

    user.Save();
}
Run Code Online (Sandbox Code Playgroud)

我用来创建PrincipalContext的用户具有修改AD对象的安全权限.如果我更新任何其他字段(例如Surname,GivenName),一切正常.

编辑:

我已经能够完成我需要做的事情(使用ADSI),但我必须在模拟下运行以下代码.模拟代码是丑陋的,下面的代码脱离了我正在更新AD数据的另一种方式(使用DirectoryServices.AccountManagement),所以我想得到一个更好的解决方案.

using (var companyOU = new DirectoryEntry("LDAP://" + company.UserAccountOU)) {
    companyOU.Invoke("MoveHere", "LDAP://" + user.DistinguishedName, "cn=Name\, Test");
}
Run Code Online (Sandbox Code Playgroud)

c# directoryservices account-management

7
推荐指数
2
解决办法
7989
查看次数