net user domain andersherum (FullName zu UserName umschlüsseln)
Rückschlüsselung von Benutzerinformationen auf Anmeldename
Bin kein Administrator, sondern "missbrauche" die Funktion wahrscheinlich nur ;)
Also mit dem Befehl "net user /domain <Anmeldename>" bekommt man ja diverse Infos über den Benutzer,
unter anderem auch "Full Name".
Ist es auch möglich, über einen Befehl Vorname, Nachname einzugeben, und dann den Username zu bekommen.
Bräuchte das für eine Liste der User.
Schonmal vielen Dank im Voraus
Also mit dem Befehl "net user /domain <Anmeldename>" bekommt man ja diverse Infos über den Benutzer,
unter anderem auch "Full Name".
Ist es auch möglich, über einen Befehl Vorname, Nachname einzugeben, und dann den Username zu bekommen.
Bräuchte das für eine Liste der User.
Schonmal vielen Dank im Voraus
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-Key: 69682
Url: https://administrator.de/contentid/69682
Ausgedruckt am: 28.03.2024 um 22:03 Uhr
1 Kommentar
Hallo AzuBIENE,
da musst Du schon den Fullname auftröseln.
Eine andere Möglichkeit wäre Script das die AD Daten ausliest.
Als Beispiel hier finduser (Quelle: ITPRO)
aufzurufen mit cscript finduser.wsf /attrib:surname=xxx oder auch givenname=yyy
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="Windows Script Host">
<comment>
This script demonstrates how to find the location of users starting with a given CN in an AD forest
</comment>
<job id="FindUser">
<runtime>
<named name="attrib" helpstring="The name of a user attribute, an equals sign and all or part of a the attribute's value."
type="string" required="true" />
<example>
Scenario: Find all users in a forest whose first name begins with Sar
Example: FindUser /attrib:givenName=sar* or FindUser /attrib:sn=smith</example>
</runtime>
<script language="VBScript">
<![CDATA[
'Option Explicit
'Use Named Arguments collection for command line args.
'The named element required WSH version 5.6
Dim objArgs, attributePart, objRootDSE
Dim firstNamePart, lastNamePart
Dim strRootAdsPath, objConnection, objCommand, objRecordSet
Set objArgs = WScript.Arguments.Named
attributePart = objArgs.Item("attrib")
'Verify that all three parameters are properly entered.
If WScript.Arguments.Named.Count <> 1 Then
WScript.Arguments.ShowUsage
WScript.Quit
ElseIf attributePart = "" Then
WScript.Echo "You did not specify an attribute for the search or there " & _
"is a missing colon after and argument parameter name. The value is " & _
vbNewLine & "attrib:attribute name=value. For example:" & _
vbNewLine & "attrib:sn = smith or attrib:givenName=Joh*" & _
vbNewLine & "Notice that partial names using wildcards is allowed, as shown in the second example" & _
vbNewLine & "See details about LDAP query dialect in the ADSI SDK"
WScript.Quit
'check that this script is being run from the console. It does not run using wscript
ElseIf Lcase(Right(Wscript.FullName, 12)) = "\wscript.exe" Then
WScript.Echo "Either switch your default script host to CScript " & _
"by running the following command:" & vbNewLine & _
"cscript h:cscript or prepend the script name with cscript as shown:" & _
vbNewLine & vbNewLine & "cscript FindUser /attrib:" & attributePart
WScript.Quit
Else
' get the root dse object
Set objRootDSE = GetObject("LDAP:rootDSE")
' get the root naming context to start the search at the root of the forest
strRootAdsPath = "GC://" & objRootDSE.Get("rootDomainNamingContext")
' create and ADO connection
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
'objCommand.CommandText = _
'"<" & strRootAdsPath & ">;(&(objectCategory=user)(cn=" & commonNamePart & "))" & _
'";distinguishedName;subtree"
objCommand.CommandText = _
"<" & strRootAdsPath & ">;(&(objectCategory=user)(" & attributePart & "))" & _
";distinguishedName;subtree"
Set objRecordSet = objCommand.Execute
WScript.Echo "Searching forest " & objRootDSE.Get("rootDomainNamingContext") & _
" for users with an attribute name and value starting with " & attributePart
If objRecordSet.EOF Then
Wscript.Echo vbNewLine & "No users found with that name"
Else
Wscript.Echo vbNewLine
Do Until objRecordset.EOF
WScript.Echo "[" & _
objRecordset.Fields("distinguishedName") & "]"
objRecordset.MoveNext
Loop
End If
objConnection.Close
End If
]]>
</script>
</job>
</package>
Gruß
@Egbert
da musst Du schon den Fullname auftröseln.
Eine andere Möglichkeit wäre Script das die AD Daten ausliest.
Als Beispiel hier finduser (Quelle: ITPRO)
aufzurufen mit cscript finduser.wsf /attrib:surname=xxx oder auch givenname=yyy
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="Windows Script Host">
<comment>
This script demonstrates how to find the location of users starting with a given CN in an AD forest
</comment>
<job id="FindUser">
<runtime>
<named name="attrib" helpstring="The name of a user attribute, an equals sign and all or part of a the attribute's value."
type="string" required="true" />
<example>
Scenario: Find all users in a forest whose first name begins with Sar
Example: FindUser /attrib:givenName=sar* or FindUser /attrib:sn=smith</example>
</runtime>
<script language="VBScript">
<![CDATA[
'Option Explicit
'Use Named Arguments collection for command line args.
'The named element required WSH version 5.6
Dim objArgs, attributePart, objRootDSE
Dim firstNamePart, lastNamePart
Dim strRootAdsPath, objConnection, objCommand, objRecordSet
Set objArgs = WScript.Arguments.Named
attributePart = objArgs.Item("attrib")
'Verify that all three parameters are properly entered.
If WScript.Arguments.Named.Count <> 1 Then
WScript.Arguments.ShowUsage
WScript.Quit
ElseIf attributePart = "" Then
WScript.Echo "You did not specify an attribute for the search or there " & _
"is a missing colon after and argument parameter name. The value is " & _
vbNewLine & "attrib:attribute name=value. For example:" & _
vbNewLine & "attrib:sn = smith or attrib:givenName=Joh*" & _
vbNewLine & "Notice that partial names using wildcards is allowed, as shown in the second example" & _
vbNewLine & "See details about LDAP query dialect in the ADSI SDK"
WScript.Quit
'check that this script is being run from the console. It does not run using wscript
ElseIf Lcase(Right(Wscript.FullName, 12)) = "\wscript.exe" Then
WScript.Echo "Either switch your default script host to CScript " & _
"by running the following command:" & vbNewLine & _
"cscript h:cscript or prepend the script name with cscript as shown:" & _
vbNewLine & vbNewLine & "cscript FindUser /attrib:" & attributePart
WScript.Quit
Else
' get the root dse object
Set objRootDSE = GetObject("LDAP:rootDSE")
' get the root naming context to start the search at the root of the forest
strRootAdsPath = "GC://" & objRootDSE.Get("rootDomainNamingContext")
' create and ADO connection
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
'objCommand.CommandText = _
'"<" & strRootAdsPath & ">;(&(objectCategory=user)(cn=" & commonNamePart & "))" & _
'";distinguishedName;subtree"
objCommand.CommandText = _
"<" & strRootAdsPath & ">;(&(objectCategory=user)(" & attributePart & "))" & _
";distinguishedName;subtree"
Set objRecordSet = objCommand.Execute
WScript.Echo "Searching forest " & objRootDSE.Get("rootDomainNamingContext") & _
" for users with an attribute name and value starting with " & attributePart
If objRecordSet.EOF Then
Wscript.Echo vbNewLine & "No users found with that name"
Else
Wscript.Echo vbNewLine
Do Until objRecordset.EOF
WScript.Echo "[" & _
objRecordset.Fields("distinguishedName") & "]"
objRecordset.MoveNext
Loop
End If
objConnection.Close
End If
]]>
</script>
</job>
</package>
Gruß
@Egbert