Jump to content

LDAP canonical name query


Recommended Posts

I must say i have hard time implementing your code in my code ;p It always exists and nothing happens. Even if i just check your script it always ends up with nothing. Added msgbox but it doesn't apear. And i was thinking about it. If i Run it like that for Domain/User list i will have to change credentials back to Administrator to change local stuff like "rename computer" or Add to Local Administrators domain account? Or it will work without problems?

$Domain = "somedomain"
; Check for special tasks
If $cmdline[0] > 0 Then
    If $cmdline[1] = "/ADAdmincheck" Then
        $rc = UserValidate($Domain, $cmdline[1], $cmdline[2], "")
        Exit $rc
    EndIf
EndIf
; Ask for login/password
$UserName = "some"
$Password = "something"

; Rerun this script under the provided credentials to check if part of admin group.
Opt("RunErrorsFatal", 0)
RunAsSet($UserName, $Domain, $Password)
If Not RunWait(@ScriptFullPath & " /ADAdmincheck " & $UserName & " " & $Password) Then Exit
;
MsgBox(1,1,"Little Test -  Shit")
;
Func UserValidate($Domain, $UserName, $Password, $InGroup = "")
    Local $NameSpace = ObjGet("WinNT:")
    Local $ADS_SECURE_AUTHENTICATION = 0x0001
    Local $DomObj = $NameSpace.OpenDSObject ("WinNT://" & $Domain, $UserName, $Password, $ADS_SECURE_AUTHENTICATION)
    If @error <> 0 Then Return 0
    If $InGroup <> "" Then
        $objUser = ObjGet("WinNT://" & $Domain & "/" & $UserName)
        For $oGroup In $objUser.Groups
            If $oGroup.Name = $InGroup Then
                Return 1
            EndIf
        Next
        Return 0
    EndIf
    Return 1
EndFunc ;==>UserValidate

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

  • Developers

I must say i have hard time implementing your code in my code ;p It always exists and nothing happens.

Forgot to mention it will only work when you compile the script and run the exe.

And i assume you will change it to use a proper userid and password and ofcourse adapt the test for the admin group.. else it will just exit.....

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Forgot to mention it will only work when you compile the script and run the exe.

And i assume you will change it to use a proper userid and password and ofcourse adapt the test for the admin group.. else it will just exit.....

Ah exe :( The others i did know :think:

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...