c# – LDAP – 检索所有属性/值的列表?
发布时间:2020-12-15 06:26:35 所属栏目:百科 来源:网络整理
导读:是否可以从LDAP中检索所有属性/值的列表,而不指定,如果可以这样做呢? 解决方法 我抓住我的DirectoryEntry类对象的所有参数的列表.我希望它会有所帮助: objectClass = System.Object[]cn = Administratorsn = Kwiatek (Last name)c = PL (Country Code)l =
|
是否可以从LDAP中检索所有属性/值的列表,而不指定,如果可以这样做呢?
解决方法
我抓住我的DirectoryEntry类对象的所有参数的列表.我希望它会有所帮助:
objectClass = System.Object[] cn = Administrator sn = Kwiatek (Last name) c = PL (Country Code) l = Warszawa (City) st = Mazowieckie (Voivodeship) title = .NET Developer description = Built-in account for administering the computer/domain postalCode = 00-000 postOfficeBox = Warszawa Ursynów physicalDeliveryOfficeName = Wojskowa Akademia Techniczna givenName = Piotr (First name) distinguishedName = CN=Administrator,CN=Users,DC=helpdesk,DC=wat,DC=edu instanceType = 4 whenCreated = 2012-11-23 06:09:28 whenChanged = 2013-02-23 13:24:41 displayName = Piotr Kwiatek (Konto administratora) uSNCreated = System.__ComObject memberOf = System.Object[] uSNChanged = System.__ComObject co = Poland company = HELPDESK streetAddress = Kaliskiego 2 wWWHomePage = http://www.piotr.kwiatek.org name = Administrator objectGUID = System.Byte[] userAccountControl = 512 badPwdCount = 0 codePage = 0 countryCode = 616 badPasswordTime = System.__ComObject lastLogoff = System.__ComObject lastLogon = System.__ComObject logonHours = System.Byte[] pwdLastSet = System.__ComObject primaryGroupID = 513 objectSid = System.Byte[] adminCount = 1 accountExpires = System.__ComObject logonCount = 178 sAMAccountName = Administrator sAMAccountType = 805306368 objectCategory = CN=Person,CN=Schema,CN=Configuration,DC=edu isCriticalSystemObject = True dSCorePropagationData = System.Object[] lastLogonTimestamp = System.__ComObject mail = spam@kwiatek.org nTSecurityDescriptor = System.__ComObject 在这里你有代码: string currentUserSid = WindowsIdentity.GetCurrent().User.Value;
PrincipalContext ctx = new PrincipalContext(
ContextType.Domain,"helpdesk.wat.edu");
UserPrincipal up = UserPrincipal.FindByIdentity(
ctx,IdentityType.Sid,currentUserSid);
/*
*
*/
DirectoryEntry entry = up.GetUnderlyingObject() as DirectoryEntry;
PropertyCollection props = entry.Properties;
/*
*
*/
foreach (string propName in props.PropertyNames)
{
if (entry.Properties[propName].Value != null)
{
Console.WriteLine(propName + " = " + entry.Properties[propName].Value.ToString());
}
else
{
Console.WriteLine(propName + " = NULL");
}
}
Console.ReadKey();
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
