Jump to content

Recommended Posts

Posted

I've been cracking away at my script for creating users folders, etc.. and I've opted to make life even harder for myself by making the thing create a security group and dump OU members into it as well before sorting out permissions on the shared folder...

 

Yeah I know! :roll:

 

 

Anyway, one major stumbling block in all of this is that I can't work out what the object references are in the user object.

 

The key one that's giving me a major headache is the one under "Logon User name"... I had thought it was sAMAccountName but that is actually the container name... (nearly a day wasted on that!).

 

So... any help much appreciated... :)

Posted

I think you're overlooking some other problem. sAMAccountName is a text attribute and it is what works in a logon box. The following snippet is JS but this kind of thing definitely should work and it's basically the same calls in VBS:

 

UserObj = GetObject("LDAP://cn=fred,cn=Users, ...

 

UserAcc = UserObj.Get("sAMAccountName");

Posted

This works for me. JS again - it happily prints sAMAccountName for the Administrator account.

 

var oADroot = GetObject("LDAP://RootDSE")
var oUser   = GetObject("LDAP://CN=Administrator,CN=Users," + oADroot.Get("defaultNamingContext"));

WScript.Echo("User logon: " + oUser.Get("sAMAccountName"));

 

 

And if that's not what you meant, were you looking for the UPN i.e. the userPrincipalName attribute? What are you actually trying to do with whatever you're looking for in a user container?

Posted

Had a chance to eat something, watch some CSI and let the brain idle for a bit and it's probably not a biggie..

 

The bit of code I was having problems with was referencing the sAMAccountname but that is not the same thing as the container name which is what you need to use in an LDAP reference.

 

Normally these are one and the same thing but you can edit the login name and not touch the container name and vice versa.... confused? well I was..

 

Anyways... Geoff provided the answer... I needed to reference objectUser.cn and bingo I get the right value... Obvious when you think about it :)

 

 

The script I'm writing btw, is this one..

http://www.edugeek.net/index.php?name=Forums&file=viewtopic&t=6898

 

... just come a little closer to be being done :)

 

 

Thanks all..

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



×
×
  • Create New...