#188272 - 2008-06-18 06:17 PM
Add Users to Groups Via LDAP provider
|
Gargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
I have tried several variants on this and can't seem to find the exact syntax needed. I continually get error -2147352567 for both @error printouts. $User is passed earlier in the code I know that it is getting translated correctly.
Using KiX 4.60 Windows Server 2003 SP2 KiXForms .Net
Version 1
$WS = GetObject("LDAP://CN=UPM_Test,OU=Login Script,OU=!Development,DC=MyDomain,DC=SubDomain,DC=SubDomain2,DC=TopLevel")
$Nul = TranslateName(3,"",3,@domain+"\"+$User,1)[0]
$WS.add ($nul.ADsPath)
@ERROR + @SERROR + @CRLF
$WS.Setinfo
@ERROR + @SERROR
Version 2
$WS = GetObject("LDAP://CN=UPM_Test,OU=Login Script,OU=!Development,DC=MyDomain,DC=subdomain,DC=subdomain2,DC=toplevel")
$Nul = TranslateName(3,"",3,@domain+"\"+$User,1)[0]
$WS.PutEx (3,"member",$Nul)
$WS.Setinfo
Edited by Gargoyle (2008-06-18 06:18 PM) Edit Reason: took out some long lines
_________________________
Today is the tomorrow you worried about yesterday.
|
Top
|
|
|
|
#188277 - 2008-06-18 11:18 PM
Re: Add Users to Groups Via LDAP provider
[Re: Gargoyle]
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
I think I remember seeing a post or two from Shawn saying that there are COM issuses with 4.60.. Can you try 4.53?
Thanks,
Kent
|
Top
|
|
|
|
#188278 - 2008-06-18 11:47 PM
Re: Add Users to Groups Via LDAP provider
[Re: Gargoyle]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4548
Loc: USA
|
I've not done this so this may be off base, but doesn't the group and the user have to be an object? Maybe this will work?
$WS = GetObject("LDAP://CN=UPM_Test,OU=Login Script,OU=!Development,DC=MyDomain,DC=SubDomain,DC=SubDomain2,DC=TopLevel")
$User =Getobject(TranslateName(3,"",3,@domain+"\"+$User,1)[0])
$WS.add ($User.ADsPath)
@ERROR + @SERROR + @CRLF
$WS.Setinfo
@ERROR + @SERROR
I don't know what Translatename returns, so its possible you will need something like $User=getobject("LDAP://" + TranslateName... )
|
Top
|
|
|
|
#188279 - 2008-06-19 12:38 AM
Re: Add Users to Groups Via LDAP provider
[Re: Gargoyle]
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11624
Loc: CA
|
Not sure that you need translate name do you?
Here is the Microsoft VB rendition of it. I went and looked and I don't currently have any KiX code for it either. I've always used the WinNT for most user/group management.
Set objOU = GetObject("LDAP://OU=Management,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("Group", "cn=atl-users")
objGroup.Put "sAMAccountName", "atl-users"
objGroup.SetInfo
objGroup.Add objUser.ADSPath
|
Top
|
|
|
|
#188280 - 2008-06-19 12:44 AM
Re: Add Users to Groups Via LDAP provider
[Re: NTDOC]
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11624
Loc: CA
|
|
Top
|
|
|
|
#188283 - 2008-06-19 02:43 AM
Re: Add Users to Groups Via LDAP provider
[Re: Gargoyle]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4548
Loc: USA
|
See How Can I Remove Group Members Whose User Accounts Reside in a Specific OU? http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan08/hey0102.mspx
Below is probably the important part... just not sure how the user/array part would go without some testing
$ADS_PROPERTY_DELETE=4
$objGroup.PutEx $ADS_PROPERTY_DELETE, "member", array(strUser)
$objGroup.SetInfo
|
Top
|
|
|
|
#188288 - 2008-06-19 04:32 PM
Re: Add Users to Groups Via LDAP provider
[Re: Allen]
|
Gargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
Here is the entire snippet
If $Checks[2] = -1
;VPN ADD
$Nul = WriteLine($FH,"Function Requested = VPN ADD"+@CRLF)
UpdateProgress(25)
$Label3.Text = "Adding VPN - Telecommute to user "+$User
$WS = GetObject("LDAP://CN=UPM_Test,OU=Login Script,OU=!Development,DC=Fabrikom,DC=Microsoft,DC=Com")
$Usr = GetObject("LDAP://"+ TranslateName(3,"",3,@domain+"\"+$User,1)[0])
$WS.add ($Usr.ADsPath)
$WS.Setinfo
If @Error = 0
$Nul = WriteLine($FH,"Added user "+$user+" to TermTelecom "+@Date+"-"+@Time+@CRLF)
Else
$Label3.Text = "Add User failed, please open a ticket!"
EndIf
ClearForm()
EndIf
Just have to get the delete to work now.
_________________________
Today is the tomorrow you worried about yesterday.
|
Top
|
|
|
|
#188306 - 2008-06-20 05:49 PM
Re: Add Users to Groups Via LDAP provider
[Re: Gargoyle]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4548
Loc: USA
|
I havent tried the following code, but based on the examples from MS and that the vbscript array() is nothing more than split(), maybe this will work.
dim $usr[0]
$WS = GetObject("LDAP://CN=UPM_Test,OU=Login Script,OU=!Development,DC=MyDomain,DC=subdomain,DC=subdomain2,DC=toplevel")
$usr[0] = TranslateName(3,"",3,@domain+"\"+$User,1)[0]
$WS.PutEx (4,"member",$usr)
$WS.Setinfo
Edited by Allen (2008-06-25 07:28 AM)
|
Top
|
|
|
|
#188422 - 2008-06-27 01:52 PM
Re: Add Users to Groups Via LDAP provider
[Re: Gargoyle]
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
I know I am late to react but this I used for the longest time and always works (2000,2003 and even in 2008)
$WS = GetObject("LDAP://CN=UPM_Test,OU=Login Script,OU=!Development,DC=MyDomain,DC=SubDomain,DC=SubDomain2,DC=TopLevel")
$Nul = TranslateName(3,"",3,@domain+"\"+$User,1)
$Nul = GetObject("LDAP://"+$Nul[0])
$WS.Add($nul.ADsPath)
@ERROR + @SERROR + @CRLF
$WS.Setinfo
@ERROR + @SERROR
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
1 registered
(Allen)
and 286 anonymous users online.
|
|
|