草庐IT

Active_Record

全部标签

c# - 从给定 AD 组中的 Active Directory 获取用户列表

我有搜索部门中所有用户的代码:stringDepartment="Billing";DirectorySearcherLdapSearcher=newDirectorySearcher();LdapSearcher.PropertiesToLoad.Add("displayName");LdapSearcher.PropertiesToLoad.Add("cn");LdapSearcher.PropertiesToLoad.Add("department");LdapSearcher.PropertiesToLoad.Add("title");LdapSearcher.Properti

c# - 在 .NET (C#) 中创建 Active Directory 用户

我需要在ActiveDirectory中创建一个新用户。我发现了几个类似下面的例子:usingSystem;usingSystem.DirectoryServices;namespacetest{classProgram{staticvoidMain(string[]args){try{stringpath="LDAP://OU=x,DC=y,DC=com";stringusername="johndoe";using(DirectoryEntryou=newDirectoryEntry(path)){DirectoryEntryuser=ou.Children.Add("CN="+u

c# - 获取 Active Directory 组的成员并检查他们是启用还是禁用

获取给定AD组中所有成员/用户的列表并确定用户是否启用(或禁用)的最快方法是什么?我们可能会谈论20K用户,所以我想避免为每个用户点击广告。 最佳答案 如果您使用的是.NET3.5及更高版本,则应查看System.DirectoryServices.AccountManagement(S.DS.AM)命名空间。在这里阅读所有相关信息:ManagingDirectorySecurityPrincipalsinthe.NETFramework3.5MSDNdocsonSystem.DirectoryServices.AccountMan

c# - 如何从 Active Directory 获取用户的电子邮件地址?

我试图在AD中获取用户的电子邮件地址,但没有成功。Stringaccount=userAccount.Replace(@"Domain\","");DirectoryEntryentry=newDirectoryEntry();try{DirectorySearchersearch=newDirectorySearcher(entry);search.PropertiesToLoad.Add("mail");//e-mailaddresseadSearchResultresult=search.FindOne();if(result!=null){returnresult.Proper

c# - 如何获取 UserPrincipal 类未表示的 Active Directory 属性

我的意思是,现在我正在使用System.DirectoryServices.AccountManagement,如果我使用UserPrincipal类,我只会看到名称、中间名等所以在我的代码中它就像UserPrincipalmyUser=newUserPrincipal(pc);myUser.Name="aaaaaa";myUser.SamAccountName="aaaaaaa";....myUser.Save();如何查看移动或信息等属性? 最佳答案 在这种情况下,您需要更深入一层-回到DirectoryEntry的内部-通过从

c# - 列出所有 Active Directory 组

以下代码列出了一些(但不是全部)ActiveDirectory组。为什么?我正在尝试列出所有安全组、分发组、计算机组等。我是否指定了错误的objectClass?privatestaticvoidListGroups(){DirectoryEntryobjADAM=default(DirectoryEntry);DirectoryEntryobjGroupEntry=default(DirectoryEntry);DirectorySearcherobjSearchADAM=default(DirectorySearcher);SearchResultCollectionobjSear

c# - 使用 C# 从 ASP.Net MVC 访问 Active Directory

我需要访问ActiveDirectory以获取有关客户所属组的信息。我的项目是一个使用C#的ASP.NetMVC应用程序。我以前从未针对ActiveDirectory进行过编程,需要一些建议,了解最好的入门方式是什么,使用什么安全模型来访问信息,也许还能给我一些好的教程。 最佳答案 由于您使用的是MVC,因此您可以访问新的System.DirectoryServices.AccountManagement.NET3.5中的命名空间。这些类应该优于DirectoryServices本身中的旧类,因为它们更易于使用。有几个陷阱在3.5中

c# - 使用 C# 检查 Active Directory 中是否存在 UserID

我们如何检查USERID是否存在于ActiveDirectory中。我有LDAP字符串和UserID,我可以找到该UserID是否存在于ActiveDirectory中。我将其用于ASP.NETWeb应用程序(.NET3.5) 最佳答案 您可以按照以下方式执行某些操作(将域替换为您要进行身份验证的域或完全删除该参数):publicboolDoesUserExist(stringuserName){using(vardomainContext=newPrincipalContext(ContextType.Domain,"DOMAIN

c# - 在 asp.net 核心项目中获取 Azure Active Directory 组

我使用VisualStudio2015创建了一个新项目,并使用针对AzureActiveDirectory的工作和学校帐户启用了身份验证。下面是生成的配置函数的样子:app.UseStaticFiles();app.UseCookieAuthentication();app.UseOpenIdConnectAuthentication(newOpenIdConnectOptions{ClientId=Configuration["Authentication:AzureAd:ClientId"],ClientSecret=Configuration["Authentication:Az

c# - 使用 C# 查找递归组成员身份 (Active Directory)

我希望获得一个用户在ActiveDirectory中所属的所有组的列表,既在memberOf属性列表中明确列出,也通过嵌套组成员身份隐式列出。例如,如果我检查UserA并且UserA是GroupA和GroupB的一部分,如果GroupB是GroupC的成员,我还想列出GroupC。为了让您更深入地了解我的申请,我将在有限的基础上这样做。基本上,我偶尔需要进行一次安全检查,以列出这些额外的成员资格。我想区分这两者,但这应该不难。我的问题是我还没有找到使这个查询有效的有效方法。ActiveDirectory上的标准文本(ThisCodeProjectArticle)显示了一种执行此操作的方