![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Search Filter to get a user's guid: I'm fetching user information using ADO and have the following: strFilter = "(&(objectCategory=person)(objectClass=user) (distinguishedName=CN=Doe\, John,OU=Users,OU=Someplace,OU=Somewhere,OU=Americas,DC=west,DC=msds,DC=someco,DC=com) (mail=*)(homemdb=*))" attributes = "givenName,sn,mail" strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter & ";" + attributes + ";subtree" This works. If I change the attributes assignment to this: attributes = "guid,givenName,sn,mail" The query fails (there is no attribute named guid so I can understand why) Is there a way to get the GUID for this user? Thanks. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Search Filter to get a user's guid: <gimme_this_gimme_that@xxxxxx> wrote in message news:83fd2cf3-4f8b-4c8a-9cff-59e47d2ddffc@xxxxxx Quote: > I'm fetching user information using ADO and have the following: > > strFilter = "(&(objectCategory=person)(objectClass=user) > (distinguishedName=CN=Doe\, > John,OU=Users,OU=Someplace,OU=Somewhere,OU=Americas,DC=west,DC=msds,DC=someco,DC=com) > (mail=*)(homemdb=*))" > attributes = "givenName,sn,mail" > strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter & ";" + > attributes + ";subtree" > > This works. > > If I change the attributes assignment to this: > attributes = "guid,givenName,sn,mail" > > The query fails (there is no attribute named guid so I can understand > why) > > Is there a way to get the GUID for this user? > > Thanks. > array. I use a function to convert byte arrays to hex strings. For example: ========= Set objUser = GetObject("LDAP://cn=Jim User,ou=West,dc=MyDomain,dc=com") arrbytGuid = objUser.objectGUID strGuid = OctetToHexStr(arrbytGuid) Wscript.Echo strGUID Function OctetToHexStr(arrbytOctet) ' Function to convert OctetString (Byte Array) to a hex string. Dim k OctetToHexStr = "" For k = 1 To Lenb(arrbytOctet) OctetToHexStr = OctetToHexStr _ & Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2) Next End Function ======== You must use a function similar to above if you retrieve the attribute value with ADO. If you bind to the object, however, you can use the GUID property method of the object. This method is a function that converts the value to a hex string for you. For example: ====== Set objUser = GetObject("LDAP://cn=Jim User,ou=West,dc=MyDomain,dc=com") strGuid = objUser.GUID Wscript.Echo strGuid ======= Other property methods of objects include Parent, Class, and AdsPath. Only the later can be retrieved (and filtered on) using ADO. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Microsoft Search Filter - block or allow? | General Discussion | |||
| MBR vs GUID - Can I Have Both? | Vista hardware & devices | |||
| Guid and Cstr | VB Script | |||
| help. Digital filter? how to de-filter? USB audio device | Vista hardware & devices | |||
| Search filter "qoutes" not working (RC2) | Vista file management | |||