0
Триша
17.12.13
✎
11:24
|
Доброго времени суток!
Получаю список доменных пользователей из Active Directory по условию запросом в хранимой процедуре. Нужно выбирать только включенные учетные записи. Как написать условие?
Если бы я получала список через объект System.DirectoryServices.DirectoryEntry, то в условии было бы (!userAccountControl:1.2.840.113556.1.4.803:=2). А как в запросе?
Запрос:
select *
from openquery(ADSI, '
select givenName, sn, sAMAccountName, displayName,
mail, telephoneNumber, department,
division, userAccountControl
,ADsPath, groupType, primaryGroupID, company, employeeType, title
from ''LDAP://DC=aaa,DC=xx,DC=ru''
where objectCategory = ''Person'' and objectClass = ''user'' order by displayName')
where sn is not null and ADsPath like '%OU=YYYY%' and not ADsPath like '%OU=ZZZZZ%';
|
|
5
Jaap Vduul
17.12.13
✎
16:20
|
''userAccountControl:1.2.840.113556.1.4.803:'' = 2'
А также сам запрос можно написать в том же формате, как и для System.DirectoryServices.DirectoryEntry
<LDAP://DC=aaa,DC=ru>;(&(objectCategory=Person...
|
|
6
Записьдампа
17.12.13
✎
16:25
|
(4) Там прямым текстом написано:
An example is when you want to query Active Directory for user class objects that are disabled. The attribute that holds this information is the userAccountControl attribute. This attribute is composed of a combination of different flags. The flag for setting the object that you want to disable is UF_ACCOUNTDISABLE, which has a value of 0x02 (2 decimal).
|
|