Aus dem Anmeldenamen das CN ermitteln
Hi,
suche in VB oder VBS eine Lösung um aus einem Domänen-Anmeldenamen (samAccountName)
z.B. Max123 den CN des Users, z.B. Max Mustermann, zu ermitteln.
Vielleicht hat jemand eine Lösung ?!
Gruss
SKID
suche in VB oder VBS eine Lösung um aus einem Domänen-Anmeldenamen (samAccountName)
z.B. Max123 den CN des Users, z.B. Max Mustermann, zu ermitteln.
Vielleicht hat jemand eine Lösung ?!
Gruss
SKID
Please also mark the comments that contributed to the solution of the article
Content-Key: 40328
Url: https://administrator.de/contentid/40328
Printed on: April 18, 2024 at 23:04 o'clock
4 Comments
Latest comment
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
Set objNetwork = CreateObject("WScript.Network") ' <= edit
objConnection.Open "Provider=ADsDSOObject;"
samAccountName = objNetwork.UserName
objCommand.ActiveConnection = objConnection
' hier den Base DN noch anpassen! <LDAP://....>
objCommand.CommandText = "<LDAP://dc=domain,dc=local>;(&(objectCategory=User)(samAccountName=" & samAccountName & "));CN"
Set objRecordset = objCommand.Execute
If objRecordset.RecordCount = 1 Then
strCN=objRecordset.fields("CN").value
end if
wscript.echo strCN
Sollte so funktionieren. Du musst lediglich den Base DN entsprechend ändern