I am using the following script to see if a user that logged into my webserver has a domain account (I'll substitute "username" for the person that is actually logged in eventually). What I really need to do is find out which container the user is in and set some variables based on that (corporate vs division access). Can anyone add to this code so the Distinguished Name prints out - I can take it from there with using inStr. This will be an include page on an IIS6 webserver.
Thanks!
Jenn
Thanks!
Jenn
Code:
strUserName = "username"
dtStart = TimeValue(Now())
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<LDAP://dc=dorner,dc=com>;(&(objectCategory=User)" & _
"(samAccountName=" & strUserName &
"));distinguishedName;sAMAccountName,name;subtree"
response.Write(objCommand.CommandText)
Set objRecordSet = objCommand.Execute
If objRecordset.RecordCount = 0 Then
response.Write("sAMAccountName: " & strUserName & " does not exist.")
Else
response.Write(strUserName & " exists.")
End If