×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

WinNT:// provider searching for user by SID ?

WinNT:// provider searching for user by SID ?

WinNT:// provider searching for user by SID ?

(OP)
Is there way to search for a user account, given it's SID, using the WinNT:// provider?  (I know it's possible with the LDAP provider, but need to do it with WinNT://)

RE: WinNT:// provider searching for user by SID ?

Then with vbscript you must enumerate a group.members collection and get the SID to compare to the SID of the one your seraching for. Do you have the username ?
Or whats the format of the SID you're searching for ?


 

RE: WinNT:// provider searching for user by SID ?

(OP)
The SID is just a string (S-xxxx-xxxx...) and I'm trying to get the account name.  I have no information on the object except the SID (no domain, no account name, etc).

RE: WinNT:// provider searching for user by SID ?

i wouldnt have thought the SID string contains any direct reference to domain or account name, you will need to contact the domain and search for the account, then contact other domains if you dont find the one you are looking for

Set objDomain = GetObject("WinNT://domainname,domain")
objDomain.Filter = Array("user")

For Each aUser In objDomain
   aUSer.SID????? not sure what property holds the SID
Next

you can search for available domains via vbs as well, whcih would be your 1st loop i guess with the for each auser being nested in that

RE: WinNT:// provider searching for user by SID ?

(OP)
I can't find the property to display the SID.  It doesn't seem to be <b>.SID</b> (this spawns an invalid property error).  I tried <b>.ObjectSID</b> as well, which doesn't generate an error, but only displays <b>?</b> when I <b>wscript.echo</b> it.

RE: WinNT:// provider searching for user by SID ?

Krinid,
Where are you getting the SID from that you need to match up to a user.

Taking a stab in the dark, I am going to guess you are looking in the registry or a workstation?

If so you can match up the SID with the profile diretory which will tell you the user ID.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\SID\ProfileImagePath

I hope you find this post helpful.  

Regards,

Mark

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

RE: WinNT:// provider searching for user by SID ?

(OP)
Mark,
I'm getting the SID from the foreign policy; when I query a WinNT object in an LDAP group, it only gives me the SID.  (User name, description, adspath, etc - everything is either blank or it shows as the SID).  (I don't know why it acts this way, and I don't have the option of changing the system.)  So unfortunately, all the info I have is the SID.

RE: WinNT:// provider searching for user by SID ?

there is a custom WinNT provder user class property

IADsUser::ObjectSID

it returns an Octet String and can be accessed through the Get method of the IADs interface...i.e. using hte WinNT provider

RE: WinNT:// provider searching for user by SID ?

It's right foreign domain with no trust or NT4 domain or Exch-5.5 use the SID-property to bind accounts together.

There is a way.....
But you need to know the group-name and the domain.
It's just a little bit tricky but I'll help you on your way
Also a little bit timeconsuming, but.......

CODE


str_SID = "S-xxxx-xxxx..."
strDom = "ICFUC"
strGrp = "GroupName"

Call fnEnumGroups(strDom, strGrp, str_SID)

Function fnEnumGroups(strDomain, strGroupName, strSID_2_Search)

    Dim objGrp, objUser, intUserSID
    Set objGrp = GetObject("WinNT://" & strDomain & "/" & strGroupName & ",group")
        objGrp.Filter = Array("user")
        For Each objUser In objGrp
            objUser.GetInfo
            intUserSID = fnGet_HexString(objUser.Get("objectSID"))
            If intUserSID = strSID_2_Search Then
                Wscript.Echo intUserSID
                Wscript.Echo objUser.Name 'or whatever attribute you may need....
                Wscript.Echo ""
                Exit Function
            End if
        
        Next
    Wscript.Echo "Nothing found on : " & strSID_2_Search & " in " & strDomain & "/" & strGroupName
    Set objGrp = Nothing    
End Function

Function fnGet_HexString(intSID)
    Dim strRet, i, b
    strRet = ""
     For i = 0 to Ubound(intSID)
        b = hex(ascb(midb(intSID,i+1,1)))
        If( len(b) = 1 ) then b = "0" & b
           strRet = strRet & b
    Next
    
    fnGet_HexString = fnHexStrToDecStr(strRet)
    
End Function

Function fnHexStrToDecStr(strSid)
 
Dim arrbytSid, lngTemp, j

ReDim arrbytSid(Len(strSid)/2 - 1)
For j = 0 To UBound(arrbytSid)
    arrbytSid(j) = CInt("&H" & Mid(strSid, 2*j + 1, 2))
Next

fnHexStrToDecStr = "S-" & arrbytSid(0) & "-" _
& arrbytSid(1) & "-" & arrbytSid(8)

lngTemp = arrbytSid(15)
lngTemp = lngTemp * 256 + arrbytSid(14)
lngTemp = lngTemp * 256 + arrbytSid(13)
lngTemp = lngTemp * 256 + arrbytSid(12)

fnHexStrToDecStr = fnHexStrToDecStr & "-" & CStr(lngTemp)

lngTemp = arrbytSid(19)
lngTemp = lngTemp * 256 + arrbytSid(18)
lngTemp = lngTemp * 256 + arrbytSid(17)
lngTemp = lngTemp * 256 + arrbytSid(16)

fnHexStrToDecStr = fnHexStrToDecStr & "-" & CStr(lngTemp)

lngTemp = arrbytSid(23)
lngTemp = lngTemp * 256 + arrbytSid(22)
lngTemp = lngTemp * 256 + arrbytSid(21)
lngTemp = lngTemp * 256 + arrbytSid(20)

fnHexStrToDecStr = fnHexStrToDecStr & "-" & CStr(lngTemp)

lngTemp = arrbytSid(25)
lngTemp = lngTemp * 256 + arrbytSid(24)

fnHexStrToDecStr = fnHexStrToDecStr & "-" & CStr(lngTemp)

End Function  

Try this, I couldn't myself until tomorrow

Best Regards / ICFUC

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close