Jump to content

Active Directory Scripts


Johny Clelland
 Share

Recommended Posts

It's not letting me download that ....

I had to delete the file for a minute, I had forgotten to remove my domain-specific info... This will probably not fix what you're doing anyway, I didn't do anything with the original code. -What attribute are you trying to modify, and are you allowing enough time for the changes to replicate (if you have more than one DC)?

Link to comment
Share on other sites

I had to delete the file for a minute, I had forgotten to remove my domain-specific info... This will probably not fix what you're doing anyway, I didn't do anything with the original code. -What attribute are you trying to modify, and are you allowing enough time for the changes to replicate (if you have more than one DC)?

We do have 3 DC Controllers. I make the change and I wait up to 5 minutes and I check to see if it worked but I don't see it updated. This was working a couple of days ago, but now all of a sudden it's not. I was just wondering if my code was wrong, but I looked over it a bunch of times, and it didn't look wrong to me.

Link to comment
Share on other sites

Hey guys, very cool of you to further enhance "ADfunctions.au3".

What would you think about a function to verify the password for a user account against a local/remote host or a domain?

Hmmm... maybe someday. I'll look into it, but in the meantime, I was able to find this:

http://www.autoitscript.com/forum/index.php?showtopic=40414

Maybe this simple script is enough for what you need?

Link to comment
Share on other sites

We do have 3 DC Controllers. I make the change and I wait up to 5 minutes and I check to see if it worked but I don't see it updated. This was working a couple of days ago, but now all of a sudden it's not. I was just wondering if my code was wrong, but I looked over it a bunch of times, and it didn't look wrong to me.

You're really not providing enough info for anyone to help you... If you want help, you need to provide as much information as you can.

What attribute are you trying to modify?

Are you passing this via the command line, or your input boxes?

Have you successfully modified this same attribute before?

Is the user in a sub-domain vs root domain (if you have more than one)?

Are you running this from a machine/account that has sufficient rights?

Link to comment
Share on other sites

You're really not providing enough info for anyone to help you... If you want help, you need to provide as much information as you can.

What attribute are you trying to modify?

Are you passing this via the command line, or your input boxes?

Have you successfully modified this same attribute before?

Is the user in a sub-domain vs root domain (if you have more than one)?

Are you running this from a machine/account that has sufficient rights?

Sorry, let me give some more info:

I've tried to modify these attributes so far:

postOfficeBox

streetAddress

description

I've tried both command line and input box but with no luck.

I'm running this from my machine and I'm a domain admin.

Link to comment
Share on other sites

Anyone happen to notice an issue with this script??

#include <adfunctions.au3>;Include the adfunctions to call

If $CmdLine[0] = 3 then
    $username = $CmdLine[1] 
    $attr = $CmdLine[2]
    $val = $CmdLine[3]
Else
    $username = inputbox("Modify Attribute","Please enter username to modify")
    $attr = inputbox("Modify Attribute","Please enter attribute to modify")
    $val = inputbox("Modify Attribute","Value")
EndIf

;Attribute = extensionAttribute1
$att_set = _ADModifyAttribute($username, $attr, $val)
;$att_set = _ADModifyAttribute("dmorand", "extensionAttribute1", "")

;and $CmdLine[0] = 0
if $att_set = 1 Then
    MsgBox(0,"Attribute Set","Your attribute has been modified!")
EndIf

I run this, and I get the message box stating that my attribute has been modified, but when I check the attribute in AD, I don't see it modified. Am I missing something???

This is the code I'm running. When I compile this to an exe I'm running it like this:

script.exe "dmorand" "postOfficeBox" "9045"

That's correct right?

Link to comment
Share on other sites

I love these functions and can't live without them.

However I can't get "_ADGetUserGroups" to work. I may be using the syntax wrong. Can someone help? I just want a simple script that gives me an array of what AD groups "User1" is in.

I thought it would be as easy as:

$ADuser = "JDoe"

_ADGetUserGroups(ByRef $usergroups, $ADUser)

Then pull the user's groups from $usergroups[1], $usergroups[2], etc.

But that doesn't work.

Link to comment
Share on other sites

To get this to work myself, I had to do it like this:

_ADGetUserGroups($loggedonusergroups, $ADUser )

$loggedonusergroups is already set by the script itself, try that and let me know what happens.

"Human kind cannot gain anything without first giving something in return, to obtain; something of equal value must be lost."The Help File is truly your friend.

Link to comment
Share on other sites

That worked perfect, not sure how I didn't get to that point in troubleshooting...

Thanks!

To get this to work myself, I had to do it like this:

_ADGetUserGroups($loggedonusergroups, $ADUser )

$loggedonusergroups is already set by the script itself, try that and let me know what happens.

Link to comment
Share on other sites

Hello,

I hate to reply to an "old topic" but do you think it would be possible to put a user into 2 domains with this script? We currently need to this temporarily as we need a real user and another ghost user serving the wiki.

thank you

Felix

Link to comment
Share on other sites

  • 2 weeks later...

Heres a computer DN search:

; _ADGetComputerDN
; Searches for computer by name and returns its distinguishedName
; Returns the computerDN if the object exists in the tree, 0 otherwise
; Function by Joachim Nordvik (jokke), 16.10.2008
Func _ADGetComputerDN($search)
    $strQuery = "<LDAP://" & $strHostServer & "/" & $strDNSDomain & ">;(objectCategory=computer);distinguishedName,name;subtree" 
    $objRecordSet = $objConnection.Execute ($strQuery)
    Do
        If $objRecordSet.Fields("name").Value = $searchThen
            Return $objRecordSet.Fields("distinguishedName").Value
        EndIf
        $objRecordSet.MoveNext
    Until $objRecordSet.EOF
    Return 0
EndFunc   ;==>_ADGetComputerDNoÝ÷ Ø*&¦ë^¬3^v+b®¶­sc²ôEWFFT6ö×WFW$Dࣲb33c¶ö&¦V7BÒö&¦V7BFòÖöFg6ö×WFW"D⣲b33c·fÇVRÒfÇVRFò6WBGG&'WFRFòÂW6R&Ææ²7G&ærgV÷C²gV÷C²FòFVÆWFRâGG&'WFP£²gVæ7Föâ'¦ö6Òæ÷&Gf²Âbãã#¤gVæ2ôEWFFT6ö×WFW$Dâb33c¶ö&¦V7BÂb33c¶GG&'WFRÂb33c·fÇVR b33c·7G%VW'ÒgV÷C²fÇC´ÄD¢òògV÷C²fײb33c·7G$÷7E6W'fW"fײgV÷C²ògV÷C²fײb33c·7G$Då4FöÖâfײgV÷C²fwC³²F7FæwV6VDæÖSÒgV÷C²fײb33c¶ö&¦V7BfײgV÷C²´G5F·7V'G&VRgV÷C° b33c¶ö&¥&V6÷&E6WBÒb33c´ö&¤6öææV7FöâäWV7WFRb33c·7G%VW'²&WG&WfRFReDâf÷"FRö&¦V7@  b33c¶ÆFöVçG'Òb33c¶ö&¥&V6÷&E6WBæfVÆG2çfÇVP b33c¶ôö&¦V7BÒö&¤vWBb33c¶ÆFöVçG'²&WG&WfRFR4ôÒö&¦V7Bf÷"FRö&¦V7@  b33c¶ôö&¦V7BävWDæfð  bb33c·fÇVRÒgV÷C²gV÷C²FVà b33c¶ôö&¦V7BåWDWÂb33c¶GG&'WFR VÇ6P b33c¶ôö&¦V7BåWBb33c¶GG&'WFRÂb33c·fÇVR VæD`  b33c¶ôö&¦V7Bå6WDæfð b33c¶ôö&¦V7BåW&vU&÷W'GÆ7@  b33c¶ôö&¦V7BÒ  &WGW&â¤VæDgVæ2³ÓÒfwCµôEWFFT6ö×WFW$D
Edited by jokke
UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

We use this code to uppdate our computer description (so it shows inn the default computer search) since we have a AutoIt written application running on every logon:

_ADUpdateComputerDN(_ADGetComputerDN(@ComputerName),"description",_ADGetObjectAttribute(@UserName,"givenName")&" "&_ADGetObjectAttribute(@UserName,"sn"))

(was unable to edit my last post, as all its content then got scrambled)

Edited by jokke
UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

I have been trying to use the _ADCreateUser() part of ADFunctions.au3, version 3.1.6, but am getting an error. Here is my test script:

#include <ADFunctions.au3>

$userou="users=ou, cityoftroy=dc, local=dc"
$user="LastNameF"
$fname="FirstName"
$lname="LastName"
$description="Test user"

_ADCreateUser($userou, $user, $fname, $lname, $description)

and here is the error:

We intercepted a COM Error !
Number is: 80072020
Windescription is: An operations error occurred.

Script Line number is: 1582

Any ideas how to correct this?

Link to comment
Share on other sites

  • Developers

shouldn't this:

$userou="users=ou, cityoftroy=dc, local=dc"

be

$userou="ou=users, dc=cityoftroy, dc=local"

?

Jos

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

  • 2 weeks later...

Hi everybody,

I have another problem:

_ADGetObjectsInOU($Groups, $ou, "(&(objectCategory=Group)(sAMAccountName=*))", 2, "cn,description,info")
retrieves for each record the cn and info field. The description field is always returned as empty even when there is text in the AD description field.

When I check with other AD browsers then I can see the description.

Does anyone know what causes this problem?

Thanks

Thomas

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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