Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to create Exchange 5.5 mailbox in VBScript

Status
Not open for further replies.

MikeK90

Technical User
Aug 21, 2007
4
US
Hey guys...I found a script (on this site) to help do this...but I am getting an error on this line.

Set objSid = CreateObject("ADsSID")

Error is telling me ActiveX component can't create the object... Any ideas?
 
I don't think I've seen ADsSID. Where did you find this code?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
I saw that code in several places... prossibly outdated though? From here it was

This was the whole snippet, basically it is grabbing the SID of an AD user to associate the mailbox to an account...


'get the SID for the account to be associated with the new mailbox
Set objSid = CreateObject("ADsSID")
objSid.SetAs ADS_SID_WINNT_PATH, "WinNT://" & strDomain & "/" & strUserID
strSidHex = objSid.GetAs(ADS_SID_HEXSTRING)

later on...
objMailbox.Put "Assoc-NT-Account", strSidHex
 
yea, I had a feeling that was it...unfortunately, the links to download ADSI 2.5 no longer work, and I can't find that dll anywhere else yet. Guess I'll keep looking. Stupid Exch 5.5.... :(
 
wait, I found it on a 3rd party site. ok, let's see if I can make any other progress. I may be back :)
 
[1]>yea, I had a feeling that was it...
Now, but if you cannot get hold of a helper com object, you are not bound to rely on that particular helper. Not only you can look for another person's similar helper control out there, you have to concentrate on what result you want to get! The rest is the smoke.

[2] You can simply replace that block with adssid by some script without it.

[2.1] Excerpt ref [tt]
'get the SID for the account to be associated with the new mailbox
Set objSid = CreateObject("ADsSID")
objSid.SetAs ADS_SID_WINNT_PATH, "WinNT://" & strDomain & "/" & strUserID
strSidHex = objSid.GetAs(ADS_SID_HEXSTRING)
[/tt]
[2.2] My replacement script would be something like this.
[tt]
'get the SID for the account to be associated with the new mailbox
dim ossid
ossid=getobject(WinNT://" & strDomain & "/" & strUserID).objectsid
strSidHex=""
for i=0 to ubound(ossid)
sbyte=right("0" & hex(ascb(midb(ossid3,i+1,1))),2)
strSidHex=strSidHex & right("0" & hex(ascb(midb(ossid3,i+1,1))),2)
next
'strSidHex has done and is ready to be used.
[/tt]
 
Amendment
I've got a typo slipped in (ossid3 should be read ossid). This is a relist.

[2.2'] My replacement script would be something like this.
[tt]
'get the SID for the account to be associated with the new mailbox
dim ossid
ossid=getobject(WinNT://" & strDomain & "/" & strUserID).objectsid
strSidHex=""
for i=0 to ubound(ossid)
sbyte=right("0" & hex(ascb(midb(ossid,i+1,1))),2)
strSidHex=strSidHex & right("0" & hex(ascb(midb(ossid,i+1,1))),2)
next
'strSidHex has done and is ready to be used.
[/tt]
 
excsue the butt in

ads.dll is registred (Microsoft MTS East)
ads.dll has the benefit of finding nested membership without the need for recursive group search, well sort of, it seems to be fairly efficient. i personally have never used it, someone else here used it in the code below


Set objSysInfo = CreateObject("ADSystemInfo")
Set objInfo = GetObject("LDAP://" & objSysInfo.ComputerName)
objInfo.GetInfoEx ARRAY("tokengroups"),0
grps = objInfo.Get("tokengroups")
Set objCvrt = CreateObject("ADs.ArrayConvert")
For i = lbound(grps) to ubound(grps)
j = grps(i)
hexSid = objCvrt.CvOctetStr2vHexStr(j)
bindSid = "LDAP://<SID=" & hexSid & ">
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top