Jump to content

Domain Logon Script (windows)


Recommended Posts

I have managed to convert our logonscript to autoit almost 100% but i am still having issues with finding a suitable way to do microsofts ifmember.exe function.

Currently I managed to find a way arround the issue with this,

If _CMD(@LogonServer & '\netlogon\ifmember Domain Admins') Then mapdrive("s:", $source & "\source")
EndIf

It's not neat but it works, I am hoping their is a better way to do this so I can remove the scripts dependancies on 3rd party apps.

Any advice, I have attached the full logon script should it be required.

logon.au3

Edited by PeterAtkin

[topic='115020'] AD Domain Logon Script[/topic]

Link to comment
Share on other sites

I have managed to convert our logonscript to autoit almost 100% but i am still having issues with finding a suitable way to do microsofts ifmember.exe function.

Currently I managed to find a way arround the issue with this,

If _CMD(@LogonServer & '\netlogon\ifmember Domain Admins') Then mapdrive("s:", $source & "\source")
EndIf

It's not neat but it works, I am hoping their is a better way to do this so I can remove the scripts dependancies on 3rd party apps.

Any advice, I have attached the full logon script should it be required.

Hi,

You could use the _AD_IsMemberOf() function from the adfunctions.au3 UDF.

get it from here: http://www.autoitscript.com/forum/index.php?showtopic=106163&hl=ad&st=0

Grtz,

Tim

Link to comment
Share on other sites

OK had a look and seems there an error in the example provided

#include <AD.au3>

Global $aUser, $sFQDN_Group

; Open Connection to the Active Directory
_AD_Open()

; Get the Fully Qualified Domain Name (FQDN) for the current user
$sFQDN_User = _AD_SamAccountNameToFQDN()

; Get an array of group names (FQDN) that the current user is immediately a member of
_AD_GetUserGroups($aUser, @UserName)
$sFQDN_Group = $aUser[1]

; Check the group membership of the specified user for the specified group
$iResult = _AD_IsMemberOf($sFQDN_Group, $sFQDN_User)
Select
    Case $iResult = 1
        MsgBox(64, "Active Directory Functions", _
                "User: " & $sFQDN_User & @CRLF & _
                "Group: " & $sFQDN_Group & @CRLF & _
                "User is a member of the specified group!")
    Case ($iResult = 0 And @error = 1)
        MsgBox(64, "Active Directory Functions", _
                "User: " & $sFQDN_User & @CRLF & _
                "Group: " & $sFQDN_Group & @CRLF & _
                "Group does not exist!")
    Case ($iResult = 0 And @error = 2)
        MsgBox(64, "Active Directory Functions", _
                "User: " & $sFQDN_User & @CRLF & _
                "Group: " & $sFQDN_Group & @CRLF & _
                "User does not exist!")
    Case ($iResult = 0)
        MsgBox(64, "Active Directory Functions", _
                "User: " & $sFQDN_User & @CRLF & _
                "Group: " & $sFQDN_Group & @CRLF & _
                "User is a not member of the specified group!")
EndSelect

; Close Connection to the Active Directory
_AD_Close()

D:\addons\autoit\Logon Script\ad_test.au3 (13) : ==> Subscript used with non-Array variable.:

$sFQDN_Group = $aUser[1]

$sFQDN_Group = $aUser^ ERROR

unfortunetly I am not too clear on the logic of this example.

[topic='115020'] AD Domain Logon Script[/topic]

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...