crelf Posted November 3, 2010 Report Share Posted November 3, 2010 I can get the UserName (aSAMAccountName or otherwise) on a Windows 7 PC pretty easily (from the environment variables), but I need to get the CommonName so I can do some active directory queires - anyone know how to do this? I've attached an example that gets the active directory groups of a user - problem is, I can't get the CommonName to input into it (eg: on my domain, my UserName is "christopher_relf" which doesn't work, my CommonName is "christopher relf" which works fine). Get User\'s Groups.vi Quote Link to comment
Cat Posted November 4, 2010 Report Share Posted November 4, 2010 I've attached an example that gets the active directory groups of a user - problem is, I can't get the CommonName to input into it (eg: on my domain, my UserName is "christopher_relf" which doesn't work, my CommonName is "christopher relf" which works fine). I apologize in advance, but have to ask the obvious question: do the CommonName and UserName always follow a format where you can derive one from the other, or was that just the case in your example? Quote Link to comment
Francois Normandin Posted November 4, 2010 Report Share Posted November 4, 2010 This command line seems to work: net group /domain <groupname>* I tested it on my XP machine and got the full list of names, don't know if it works the same with Win7. Assuming ActiveDirectory didn't change syntax... it should. Credits EDIT: Reading your question again, I guess it doesn't answer your question which is how to get CommonName from UserName... If you don't know the group, how can you get a list. Quote Link to comment
Francois Normandin Posted November 4, 2010 Report Share Posted November 4, 2010 Perhaps you can build yourself a look-up table (not fast access) of all the users on the domain or a specific group. Usernames&CommonNames.vi 1 Quote Link to comment
asbo Posted November 4, 2010 Report Share Posted November 4, 2010 It's pretty easy to get through WMI: Set objSysInfo = CreateObject("ADSystemInfo") strUserDN = objSysInfo.UserNameSet objUser = GetObject("LDAP://" & strUserDN)Wscript.Echo objUser.cn but I don't know a slick way of getting that information back to LabVIEW outside of writing it to temp file. ref: http://www.windowsitpro.com/article/tips/q-how-can-my-batch-retrieve-the-common-name-of-the-current-user-.aspx Quote Link to comment
crelf Posted November 4, 2010 Author Report Share Posted November 4, 2010 Perhaps you can build yourself a look-up table (not fast access) of all the users on the domain or a specific group. Perfect - that's *exactly* what I wanted Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.