Tag: active directory

ASP.NET / Active Directory – 支持域用户的自动登录

我正在开发一个简单的ASP.NET网站,它将在WS2008(IIS7)盒子上的Intranet上运行,并响应运行XP / IE8的用户。 一切都是域连接的,我试图像SharePoint一样自动登录用户。 在我的开发机器(XP)上,当通过VS运行站点时,一切正常。 我可以完美地接收用户。 我使用以下设置: 但是,当我发布到WS2008框时,它不起作用。 显然,我在IIS7中缺少一个支持此设置的设置。 我在网站上有以下身份validation设置: Anon Auth – Enabled ASP.NET Impersonation – Enabled Basic Auth – Disabled Forms Auth – Disabled Windows Auth – Disabled 我错过了什么? 谢谢

如何查找Active Directory的全局编录?

我想在GC://DC=xxx,DC=yyy,DC=zzz格式的Active Directory环境中搜索用户。 但是,如何在仲裁Active Directory环境中以编程方式查找全局编录? 每个域名是否始终对应于全局编录? 任何替代方法我都可以尝试? 注意: Forest.FindAllGlobalCatalogs()返回服务器名称列表,但实际上我无法使用它们进行搜索。 Edit1:这就是我想要做的:假设我的activedirectory有一个名为domain1.root.com的域,然后我将使用GC:// DC = domain1,DC = root,DC = com来搜索用户。 但这总是全球目录吗? 每个域都必须有一个全局目录吗? Edit2:我现在可以使用以下代码搜索用户: var currentForest = Forest.GetCurrentForest(); var globalCatalog = currentForest.FindGlobalCatalog(); Console.WriteLine(globalCatalog.Name); //DirectorySearcher searcher = new DirectorySearcher(“GC://”+y.Name); DirectorySearcher searcher = globalCatalog.GetDirectorySearcher(); searcher.Filter = @”samaccountname=skaranth”; Console.WriteLine(searcher.SearchRoot.Path); var result = searcher.FindOne(); if(result!=null) Console.WriteLine(result.Properties[“distinguishedname”][0]); searcher.Dispose(); globalCatalog.Dispose(); currentForest.Dispose();

如何检查LDAP上是否存在用户

我需要使用他们的用户名来validation公司中的用户 – 而不是他们的密码。 所以我需要这样的方法 public bool UserExists(string username) { … } 我知道System.DirectoryServices命名空间,但不知道从哪里开始。 有任何想法吗? 有80,000多条记录,所以请记住这一点。 谢谢。 编辑: 我做到了 – 我的代码是: private bool UserExists(string userName, string domain) { try { DirectoryEntry.Exists(“WinNT://” + domain + “.[hidden].com/” + userName); return true; } catch (COMException) { return false; } } 我不知道它是否正确,但它似乎到目前为止工作。 迈克尔的答案有两个相关部分: http://www.codeproject.com/KB/system/everythingInAD.aspx#22 http://www.codeproject.com/KB/system/everythingInAD.aspx#35 更新#2: 我实际上用过这个: public static bool LoggedOnUserExists() […]

使用ASP.NET获取Active Directory信息,无需用户名和密码

我试图从ASP.NET Web应用程序获取用户在本地网络上的Active Directory信息。 Web应用程序正在本地网络上的IIS上运行。 我想要的:当用户登录网站时,他们可以从Active Directory中看到他们的姓名,用户名,电子邮件和图片。 问题是,当他们进入他们的网站时,Web应用程序要求输入用户名和密码。 用户在打开PC时已经输入了用户名和密码。 所以他们不应该再做一次。 用户使用其用户名和密码登录PC。 我可以获得域名和用户名: string adInfo = Request.ServerVariables[“LOGON_USER”]; 我还可以在测试System.DirectoryServices时在我的本地PC上获取Active Directory信息,但是当其他用户在本地尝试此Web应用程序时,会出现用户名和密码对话框。 如何才能使用户无需输入用户名和密码即可进入其网站? 我在这里尝试了所有样品,但我找不到任何解决方案。 我想我错过了一些重要的事情。

创建DirectoryEntry实例以用于测试

我正在尝试创建DirectoryEntry的实例,以便我可以使用它来测试将传递DirectoryEntry的一些代码。 然而,尽管有很多尝试,我找不到实例化DE的方法并初始化它的PropertyCollection。 我有以下代码,这些代码是从SO上的另一个答案中获取和修改的,它正在执行相同的过程但是对于SearchResult对象。 似乎Add方法已被完全禁用,我无法找到一种方法来调用PropertyCollection上的构造函数来传递一些属性。 using System.Collections; using System.DirectoryServices; using System.Globalization; using System.Reflection; using System.Runtime.Serialization; public static class DirectoryEntryFactory { const BindingFlags nonPublicInstance = BindingFlags.NonPublic | BindingFlags.Instance; const BindingFlags publicInstance = BindingFlags.Public | BindingFlags.Instance; public static DirectoryEntry Construct(T anonInstance) { var e = GetUninitializedObject(); SetPropertiesField(e); var dictionary = (IDictionary)e.Properties; var type = typeof(T); var propertyInfos = […]

查询Active Directory直接获取专有名称的email属性?

我现在正在Active Directory中进行一些查询,我们的数据库用户id与活动目录用户id的匹配。 我传递用户ID以及域和路径以获得我需要的东西。 我的努力是从传递的用户ID获取经理的电子邮件地址。 当我获得manager属性时,我返回的是可分辨名称。 在Active Directory中查找用户的经理记录 上面的post是我的确切问题,但它是一个旧post,并且没有关于如何前进的进一步描述,OP知道下一步如何使用专有名称。 事实是,我没有。 所以我的问题是,如何从我迄今为止存储的可分辨名称中获取电子邮件地址属性,该字符串的前缀为LDAP:// +“MyDistinguishedName”? public string GetManagerEmail(string ActiveDirectoryPath, string ActiveDirectoryDomain, bool email) { DirectoryEntry entry = new DirectoryEntry(ActiveDirectoryPath); try { DirectorySearcher search = new DirectorySearcher(entry); search.Filter = “(SAMAccountName=” + workerID + “)”; search.PropertiesToLoad.Add(“cn”); search.PropertiesToLoad.Add(“givenname”); //firstname search.PropertiesToLoad.Add(“sn”);//surname search.PropertiesToLoad.Add(“manager”); search.PropertiesToLoad.Add(“email”); SearchResult result = search.FindOne(); if (null == result) { return […]

Active Directory显示表中的所有属性

我试图实现一个LDAP查询来收集我们有关用户的所有属性,而不事先指定属性,我想在表中显示这个,所以使用下面的代码。 如果我取消注释search.PropertiesToLoad.Add(“cn”); line并将以相同的方式显示我添加的任何其他属性,但在我对所有属性进行完整搜索时则不会。 DirectoryEntry myLdapConnection = createDirectoryEntry(); DirectorySearcher search = new DirectorySearcher(myLdapConnection); search.CacheResults = true; //search.PropertiesToLoad.Add(“cn”); SearchResultCollection allResults = search.FindAll(); DataTable resultsTable = new DataTable(“Results”); //add columns for each property in results foreach (string colName in allResults.PropertiesLoaded) resultsTable.Columns.Add(colName, colName.GetType()); //loop to add records to DataTable foreach (SearchResult result in allResults) { int tmp = result.Properties.Count; […]

PrincipalContext和UserPrincipal如何知道密码何时到期?

我有一个UserPrincipal对象具有很多属性,但我找不到密码到期日期的属性。 如何才能做到这一点?

将byte 或object转换为GUID

我为对象数据类型分配了一些值,比如 object objData =dc.GetDirectoryEntry().Properties[“objectGUID”].Value; 这个对象重新调整像{byte[16]} [0]: 145 [1]: 104 [2]: 117 [3]: 139 [4]: 124 [5]: 15 [6]: 255 [7]: 68 [8]: 142 [9]: 159 [10]: 208 [11]: 102 [12]: 148 [13]: 157 [14]: 179 [15]: 75 然后我将这个对象转换为byte [],就像 byte[] binaryData = objData as byte[]; 它也将返回如{byte[16]} [0]: 145 [1]: 104 [2]: 117 [3]: 139 [4]: […]

PrincipalContext.ValidateCredentials使用NetBios名称在受信任域中变慢

我已经创建了一个服务,使用System.DirectoryServices.AccountManagementvalidation针对Active Directory的凭据。 我需要针对本地域以及可信域validation凭据。 在我的计算机上运行时,本地和受信任域的validation凭据的响应时间很快。 当我将此服务移动到我们的服务器时,本地域响应很快,但受信任的域响应非常慢(20 – 30秒)。 我还发现,如果我将PrincipalContext中的域名从NetBios名称更改为DNS名称,则会更正服务器上的性能问题。 这是一些例子 PrincipalContext context = new PrincipalContext(ContextType.Domain, sNetBiosName) context.ValidateCredentials(sUsername, sPassword) 在服务器上,使用NetBios名称需要20-30秒 PrincipalContext context = new PrincipalContext(ContextType.Domain, sDNSName) context.ValidateCredentials(sUsername, sPassword) 使用DNS名称,响应为0-2秒 有关需要在服务器上设置什么以便使用NetBios名称加快速度的任何想法?