I think it's 'cn'.
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!
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...
I think it's 'cn'.
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");
This works for me. JS again - it happily prints sAMAccountName for the Administrator account.
Code: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?
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..
... just come a little closer to be being done
Ohhh.. I geddit.. essentially the difference between the account name e.g. "Joe E Bloggs" and whatever you picked for the logon e.g. "jbloggs".
There are currently 1 users browsing this thread. (0 members and 1 guests)