8

我正在使用内置的 .NET System.DirectoryServices.ActiveDirectory 来访问 Active Directory 域控制器。

我正在尝试从服务器枚举用户属性的集合——不是值,而是任何用户的可修改设置列表。

本质上,这是来自 Active Directory 中“属性编辑器”的可写属性的镜像:

ADUC 用户属性

我尝试使用以下代码获取此数据:

    ActiveDirectorySchema currSchema = ActiveDirectorySchema.GetSchema(directoryContext);

    ActiveDirectorySchemaClass userSchema = currSchema.FindClass("user");

    ReadOnlyActiveDirectorySchemaPropertyCollection userProperties = userSchema.GetAllProperties();

但这会返回许多根本不在此对话中的属性,但我不知道是什么让这些属性独一无二/特别。

我也试过 FindClass("person");

有没有办法做到这一点?

更新

根据要求,如果我提出上述要求,我会得到以下结果:

使用 FindClass("person")

cn    
instanceType      
nTSecurityDescriptor      
objectCategory    
objectClass   
adminDescription      
adminDisplayName      
allowedAttributes     
allowedAttributesEffective    
allowedChildClasses   
allowedChildClassesEffective      
attributeCertificateAttribute     
bridgeheadServerListBL    
canonicalName     
createTimeStamp   
description   
directReports     
displayName   
displayNamePrintable      
distinguishedName     
dSASignature      
dSCorePropagationData     
extensionName     
flags     
fromEntry     
frsComputerReferenceBL    
fRSMemberReferenceBL      
fSMORoleOwner     
isCriticalSystemObject    
isDeleted     
isPrivilegeHolder     
isRecycled    
lastKnownParent   
managedObjects    
masteredBy    
memberOf      
modifyTimeStamp   
mS-DS-ConsistencyChildCount   
mS-DS-ConsistencyGuid     
msCOM-PartitionSetLink    
msCOM-UserLink    
msDFSR-ComputerReferenceBL    
msDFSR-MemberReferenceBL      
msDS-Approx-Immed-Subordinates    
msDS-AuthenticatedToAccountlist   
msDS-EnabledFeatureBL     
msDS-HostServiceAccountBL     
msDS-IsDomainFor      
msDS-IsFullReplicaFor     
msDS-IsPartialReplicaFor      
msDS-KrbTgtLinkBl     
msDS-LastKnownRDN     
msDS-LocalEffectiveDeletionTime   
msDS-LocalEffectiveRecycleTime    
msDs-masteredBy   
msDS-MembersForAzRoleBL   
msDS-NC-RO-Replica-Locations-BL   
msDS-NCReplCursors    
msDS-NCReplInboundNeighbors   
msDS-NCReplOutboundNeighbors      
msDS-NcType   
msDS-NonMembersBL     
msDS-ObjectReferenceBL    
msDS-OIDToGroupLinkBl     
msDS-OperationsForAzRoleBL    
msDS-OperationsForAzTaskBL    
msDS-PrincipalName    
msDS-PSOApplied   
msDS-ReplAttributeMetaData    
msDS-ReplValueMetaData    
msDS-RevealedDSAs     
msDS-RevealedListBL   
msDS-TasksForAzRoleBL     
msDS-TasksForAzTaskBL     
msSFU30PosixMemberOf      
name      
netbootSCPBL      
nonSecurityMemberBL   
objectGUID    
objectVersion     
otherWellKnownObjects     
ownerBL   
partialAttributeDeletionList      
partialAttributeSet   
possibleInferiors     
proxiedObjectName     
proxyAddresses    
queryPolicyBL     
replPropertyMetaData      
replUpToDateVector    
repsFrom      
repsTo    
revision      
sDRightsEffective     
seeAlso   
serialNumber      
serverReferenceBL     
showInAdvancedViewOnly    
siteObjectBL      
sn    
structuralObjectClass     
subRefs   
subSchemaSubEntry     
systemFlags   
telephoneNumber   
url   
userPassword      
uSNChanged    
uSNCreated    
uSNDSALastObjRemoved      
USNIntersite      
uSNLastObjRem     
uSNSource     
wbemPath      
wellKnownObjects      
whenChanged   
whenCreated   
wWWHomePage   

使用 FindClass("user")

cn    
instanceType      
nTSecurityDescriptor      
objectCategory    
objectClass   
objectSid     
sAMAccountName    
accountExpires    
accountNameHistory    
aCSPolicyName     
adminCount    
adminDescription      
adminDisplayName      
allowedAttributes     
allowedAttributesEffective    
allowedChildClasses   
allowedChildClassesEffective      
altSecurityIdentities     
assistant     
attributeCertificateAttribute     
audio     
badPasswordTime   
badPwdCount   
bridgeheadServerListBL    
businessCategory      
c     
canonicalName     
carLicense    
co    
codePage      
comment   
company   
controlAccessRights   
countryCode   
createTimeStamp   
dBCSPwd   
defaultClassStore     
department    
departmentNumber      
description   
desktopProfile    
destinationIndicator      
directReports     
displayName   
displayNamePrintable      
distinguishedName     
division      
dSASignature      
dSCorePropagationData     
dynamicLDAPServer     
employeeID    
employeeNumber    
employeeType      
extensionName     
facsimileTelephoneNumber      
flags     
fromEntry     
frsComputerReferenceBL    
fRSMemberReferenceBL      
fSMORoleOwner     
garbageCollPeriod     
gecos     
generationQualifier   
gidNumber     
givenName     
groupMembershipSAM    
groupPriority     
groupsToIgnore    
homeDirectory     
homeDrive     
homePhone     
homePostalAddress     
houseIdentifier   
info      
initials      
internationalISDNNumber   
ipPhone   
isCriticalSystemObject    
isDeleted     
isPrivilegeHolder     
isRecycled    
jpegPhoto     
l     
labeledURI    
lastKnownParent   
lastLogoff    
lastLogon     
lastLogonTimestamp    
legacyExchangeDN      
lmPwdHistory      
localeID      
lockoutTime   
loginShell    
logonCount    
logonHours    
logonWorkstation      
mail      
managedObjects    
manager   
masteredBy    
maxStorage    
memberOf      
mhsORAddress      
middleName    
mobile    
modifyTimeStamp   
mS-DS-ConsistencyChildCount   
mS-DS-ConsistencyGuid     
mS-DS-CreatorSID      
msCOM-PartitionSetLink    
msCOM-UserLink    
msCOM-UserPartitionSetLink    
msDFSR-ComputerReferenceBL    
msDFSR-MemberReferenceBL      
msDRM-IdentityCertificate     
msDS-AllowedToDelegateTo      
msDS-Approx-Immed-Subordinates    
msDS-AuthenticatedAtDC    
msDS-AuthenticatedToAccountlist   
msDS-Cached-Membership    
msDS-Cached-Membership-Time-Stamp     
msDS-EnabledFeatureBL     
msDS-FailedInteractiveLogonCount      
msDS-FailedInteractiveLogonCountAtLastSuccessfulLogon     
msDS-HABSeniorityIndex    
msDS-HostServiceAccountBL     
msDS-IsDomainFor      
msDS-IsFullReplicaFor     
msDS-IsPartialReplicaFor      
msDS-KeyVersionNumber     
msDS-KrbTgtLinkBl     
msDS-LastFailedInteractiveLogonTime   
msDS-LastKnownRDN     
msDS-LastSuccessfulInteractiveLogonTime   
msDS-LocalEffectiveDeletionTime   
msDS-LocalEffectiveRecycleTime    
msDs-masteredBy   
msDS-MembersForAzRoleBL   
msDS-NC-RO-Replica-Locations-BL   
msDS-NCReplCursors    
msDS-NCReplInboundNeighbors   
msDS-NCReplOutboundNeighbors      
msDS-NcType   
msDS-NonMembersBL     
msDS-ObjectReferenceBL    
msDS-OIDToGroupLinkBl     
msDS-OperationsForAzRoleBL    
msDS-OperationsForAzTaskBL    
msDS-PhoneticCompanyName      
msDS-PhoneticDepartment   
msDS-PhoneticDisplayName      
msDS-PhoneticFirstName    
msDS-PhoneticLastName     
msDS-PrincipalName    
msDS-PSOApplied   
msDS-ReplAttributeMetaData    
msDS-ReplValueMetaData    
msDS-ResultantPSO     
msDS-RevealedDSAs     
msDS-RevealedListBL   
msDS-SecondaryKrbTgtNumber    
msDS-Site-Affinity    
msDS-SourceObjectDN   
msDS-SupportedEncryptionTypes     
msDS-TasksForAzRoleBL     
msDS-TasksForAzTaskBL     
msDS-User-Account-Control-Computed    
msDS-UserPasswordExpiryTimeComputed   
msExchAssistantName   
msExchHouseIdentifier     
msExchLabeledURI      
msIIS-FTPDir      
msIIS-FTPRoot     
mSMQDigests   
mSMQDigestsMig    
mSMQSignCertificates      
mSMQSignCertificatesMig   
msNPAllowDialin   
msNPCallingStationID      
msNPSavedCallingStationID     
msPKI-CredentialRoamingTokens     
msPKIAccountCredentials   
msPKIDPAPIMasterKeys      
msPKIRoamingTimeStamp     
msRADIUS-FramedInterfaceId    
msRADIUS-FramedIpv6Prefix     
msRADIUS-FramedIpv6Route      
msRADIUS-SavedFramedInterfaceId   
msRADIUS-SavedFramedIpv6Prefix    
msRADIUS-SavedFramedIpv6Route     
msRADIUSCallbackNumber    
msRADIUSFramedIPAddress   
msRADIUSFramedRoute   
msRADIUSServiceType   
msRASSavedCallbackNumber      
msRASSavedFramedIPAddress     
msRASSavedFramedRoute     
msSFU30Name   
msSFU30NisDomain      
msSFU30PosixMemberOf      
msTSAllowLogon    
msTSBrokenConnectionAction    
msTSConnectClientDrives   
msTSConnectPrinterDrives      
msTSDefaultToMainPrinter      
msTSExpireDate    
msTSExpireDate2   
msTSExpireDate3   
msTSExpireDate4   
msTSHomeDirectory     
msTSHomeDrive     
msTSInitialProgram    
msTSLicenseVersion    
msTSLicenseVersion2   
msTSLicenseVersion3   
msTSLicenseVersion4   
msTSLSProperty01      
msTSLSProperty02      
msTSManagingLS    
msTSManagingLS2   
msTSManagingLS3   
msTSManagingLS4   
msTSMaxConnectionTime     
msTSMaxDisconnectionTime      
msTSMaxIdleTime   
msTSPrimaryDesktop    
msTSProfilePath   
msTSProperty01    
msTSProperty02    
msTSReconnectionAction    
msTSRemoteControl     
msTSSecondaryDesktops     
msTSWorkDirectory     
name      
netbootSCPBL      
networkAddress    
nonSecurityMemberBL   
ntPwdHistory      
o     
objectGUID    
objectVersion     
operatorCount     
otherFacsimileTelephoneNumber     
otherHomePhone    
otherIpPhone      
otherLoginWorkstations    
otherMailbox      
otherMobile   
otherPager    
otherTelephone    
otherWellKnownObjects     
ou    
ownerBL   
pager     
partialAttributeDeletionList      
partialAttributeSet   
personalTitle     
photo     
physicalDeliveryOfficeName    
possibleInferiors     
postalAddress     
postalCode    
postOfficeBox     
preferredDeliveryMethod   
preferredLanguage     
preferredOU   
primaryGroupID    
primaryInternationalISDNNumber    
primaryTelexNumber    
profilePath   
proxiedObjectName     
proxyAddresses    
pwdLastSet    
queryPolicyBL     
registeredAddress     
replPropertyMetaData      
replUpToDateVector    
repsFrom      
repsTo    
revision      
rid   
roomNumber    
sAMAccountType    
scriptPath    
sDRightsEffective     
secretary     
securityIdentifier    
seeAlso   
serialNumber      
serverReferenceBL     
servicePrincipalName      
shadowExpire      
shadowFlag    
shadowInactive    
shadowLastChange      
shadowMax     
shadowMin     
shadowWarning     
showInAddressBook     
showInAdvancedViewOnly    
sIDHistory    
siteObjectBL      
sn    
st    
street    
streetAddress     
structuralObjectClass     
subRefs   
subSchemaSubEntry     
supplementalCredentials   
systemFlags   
telephoneNumber   
teletexTerminalIdentifier     
telexNumber   
terminalServer    
textEncodedORAddress      
thumbnailLogo     
thumbnailPhoto    
title     
tokenGroups   
tokenGroupsGlobalAndUniversal     
tokenGroupsNoGCAcceptable     
uid   
uidNumber     
unicodePwd    
unixHomeDirectory     
unixUserPassword      
url   
userAccountControl    
userCert      
userCertificate   
userParameters    
userPassword      
userPKCS12    
userPrincipalName     
userSharedFolder      
userSharedFolderOther     
userSMIMECertificate      
userWorkstations      
uSNChanged    
uSNCreated    
uSNDSALastObjRemoved      
USNIntersite      
uSNLastObjRem     
uSNSource     
wbemPath      
wellKnownObjects      
whenChanged   
whenCreated   
wWWHomePage   
x121Address   
x500uniqueIdentifier    

澄清返回的数据

用户模式

用户模式

用户属性

用户属性

4

2 回答 2

1

允许为对象修改的属性列表存储在属性allowedAttributesEffective中。

它将显示进行查询的安全上下文的属性。

查看此博客文章了解更多信息

于 2012-10-25T22:07:52.390 回答
0

“但这会返回许多根本不在此对话中的属性,但我不知道是什么让这些属性独一无二/特别。”

Windows 服务器带有预定义的 AD 架构。这是唯一/特殊值的基本列表。例如,如果您安装了 Exchange 服务器,则 Exchange 将向列表中添加一大堆额外的唯一/特殊属性,因为它会将 Exchange AD 架构附加到您的基本 Windows AD 架构。本质上,基本 Windows AD 安装将向您显示您保证的架构对象,所有其他对象都是可选的,具体取决于您的网络上的配置和安装的软件。

我强烈建议使用 adsi 编辑器管理单元进行此类编程: http ://technet.microsoft.com/en-us/library/cc773354%28v=ws.10%29.aspx 。这将帮助您了解可以将哪些魔术字符串放入 FindClass 并将调用作为参数,并允许您在进入代码之前通过 C# 调用确定从 AD 返回的内容。

于 2012-09-27T01:36:10.393 回答