Tag: active directory

将启用的计算机添加到Active Directory OU

我正在尝试以编程方式将计算机添加到我公司的Active Directory中。 我现在在互联网上搜索这么久了,但我找不到解决办法。 我的代码: DirectoryEntry dirEntry = new DirectoryEntry(“LDAP://OU=ou2example,OU=ou1example,DC=site,DC=company,DC=com”); dirEntry.Username = “username”; dirEntry.Password = “password”; DirectoryEntry newComputer = dirEntry.Children.Add(“CN=” + ComputerName, “computer”); newComputer.CommitChanges(); 我的问题: 计算机已添加到Active Directory中。 但它被标记为已禁用。 我试着跟随启用计算机: newComputer.Properties[“userAccountControl”].Value = 0x200; 但我得到一个DirectoryServicesCOMException – >服务器无法完成请求。 要么 newComputer.Properties[“Enabled”].Value = true; 但是我得到一个DirectoryServicesCOMException – >请求的操作不满足至少一个针对此对象类条件的约束。 请注意,例外情况从德语翻译成英语! 谢谢你的帮助!

从adlds实例validationasp.net mvc 5应用程序

您好我想集成LDAP(安装在Windows 8.1机器上的AD LDS)表格validation到我的mvc 5应用程序。 我不知道我是否遗漏了web.config上的内容或我的c#代码错误但我已成功连接ldp.exe和ADSI编辑为User = Admin,其管理员权限如此处所示 在我的网络配置中我添加了这些行: 我的登录方法请注意我正在传递(txtDomainName = App.com,txtUserName = Admin,txtPassword = Azerty * 123): [AllowAnonymous] [HttpGet] public ActionResult Login () { return View(); } [AllowAnonymous] [HttpPost] public ActionResult Login(string txtDomainName, string txtUserName, string txtPassword) { // Path to you LDAP directory server. // Contact your network administrator to obtain a valid path. […]

喜欢在ActiveDirectory中搜索

我在C#中使用以下代码搜索LDAP以轮询用户的活动目录: DirectoryEntry entry = new DirectoryEntry(ldapPath, userName, password); DirectorySearcher Searcher = new DirectorySearcher(entry); Searcher.CacheResults = true; Searcher.SearchScope = SearchScope.Subtree; Searcher.Filter = “(&(&(objectCategory=person)(objectClass=user)) (|(samaccountname=” + userSearch.SamAccountName + “*) (&(GivenName=” + userSearch.FirstName + “*)(SN=” + userSearch.Surname + “*))))”; Searcher.PropertiesToLoad.AddRange(new string[] {“DisplayName”, “GivenName”, “DistinguishedName”,”Title”,”manager”, “mail”, “physicalDeliveryOfficeName”, “DirectReports”, “Company”, “Description”, “SAMAccountName”}); SearchResultCollection results = Searcher.FindAll(); List activeUsers = new […]

在Active Directory中,如何确定ActiveDirectoryAccessRule的类型?

我可以使用诸如的代码获取Active Directory对象的访问规则集合 ActiveDirectorySecurity ads = directoryEntry.ObjectSecurity; AuthorizationRuleCollection arc = ads.GetAccessRules(true, true, typeof(NTAccount)); foreach (ActiveDirectoryAccessRule adar in arc) { // get rule properties } 但是,我想知道每条规则是否也属于ActiveDirectoryAccessRule子类型之一,例如PropertyAccessRule。 这可能吗? 我没有看到提供此信息的类属性。

C#ActiveDirectory LDAP组查询

基本上我要做的是,我有一个ASP.Net Web应用程序,它使用Forms Authentication和一些自定义代码将它链接到ActiveDirectory(非常类似于它的工作原理)。 但是,每当我查询用户组的域控制器时,它只返回它们明确在的组而不是子组(id est,用户所属的特定安全组,比如组A,即组成员我想要的组,比如组B,用户明确在组A中,但只是隐含在组B中,因为组A是组B的成员)。 我已经阅读了tokenGroups查询可以帮助我在这里,但目前我没有办法解析这些数据。 然而,最可取的是,如果我可以通过LDAP查询传递某些组,并且如果该用户位于该组内,则让Domain控制器只给我一个布尔值(true / false)。 有什么建议?

c#更改AD密码Directoryservices

我试图让以下代码工作,问题是,有时它确实,有时它没有。 当它失败时,它会给出错误0x800704F1“系统无法联系域控制器来为身份validation请求提供服务”我说它有90%的时间失败。 我已经尝试通过在上下文类型后添加它来给它一个静态DC这可悲的没有帮助。 在管理员用户,它总是工作..但我相信用户应该能够更改自己的密码。 在user.changepassword行上触发错误 我希望别人有一个好主意。 using (var context = new PrincipalContext(ContextType.Domain)) { using (var user = UserPrincipal.Current) { try { user.ChangePassword(txt_old.Text, txt_new.Text); user.Save(); } catch(Exception p) { if (p.HResult.Equals(“0x800708C5”))//Not secure enough according to password policy { MessageBox.Show(“Volgens het systeem is uw nieuwe wachtwoord niet veilig genoeg, voldoet het aan alle eisen?”, “Niet gelukt”, MessageBoxButtons.OK, […]

我可以从WindowsPrincipal获取Active Directory属性吗?

我想获取当前登录用户的Employee-ID。 这在一些.Net类中是否容易获得,还是需要进行某种LDAP查询? 欢迎任何提示

是否有更好(更简单)的方法来获取特定域的SID?

我被指派修改WinForms应用程序,基本上检查登录用户是否属于特定域。 这是我到目前为止所提出的: byte[] domainSid; var directoryContext = new DirectoryContext(DirectoryContextType.Domain, “domain.se”); using (var domain = Domain.GetDomain(directoryContext)) using (var directoryEntry = domain.GetDirectoryEntry()) domainSid = (byte[])directoryEntry.Properties[“objectSid”].Value; var sid = new SecurityIdentifier(domainSid, 0); bool validUser = UserPrincipal.Current.Sid.IsEqualDomainSid(sid); 有没有更好/更简单的方法来做到这一点? 对我来说,似乎可以使用PrincipalContext或System.Security.Principal中的其他类以某种方式访问​​domainSid。 我考虑过使用硬编码的SID字符串,但我不知道它是多么“正确”。

如何使用c#使用DomainName获取AD中的OU名称列表?

我想从Active Directory获取OU列表。 我只有域名。 我怎样才能用c#实现这个目标?

获取“成员”组的用户

我得到了一个有效的解决方案,但我非常确定资源密集度较低的方法,因为当前的解决方案包括进行查询以获取组成员,然后查询以获取每个用户的信息。 这是我的代码: DirectoryEntry root = new DirectoryEntry( “LDAP://server:port” ); DirectorySearcher searcher = new DirectorySearcher( root ); searcher.Filter = “(&(ObjectClass=Group)(CN=foo-group))”; var members = (IEnumerable)searcher.FindOne() .GetDirectoryEntry() .Invoke( “members” ); Dictionary results = new Dictionary(); foreach( object member in members ) { DirectoryEntry de = new DirectoryEntry( member ); results.Add( de.Properties[ “SAMAccountname” ][ 0 ].ToString(), de.Properties[ “cn” ][ […]