Page 1 of 1 1
Topic Options
#129361 - 2004-11-11 06:54 PM Get the department name from Active Directory.
Anonymous
Unregistered


I need to enumerate the Department for a user from AD. Can someone post a code snippet on how to do that in KixTart. I have tried searching for examples here but nothing talks about how to get what I want.

-Al

Top
#129362 - 2004-11-11 07:03 PM Re: Get the department name from Active Directory.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
First off, it is NOT KixTart, it is KiXtart.

You could not have used the right seach words as the UDF, "GroupMembers() - returns all members of a given group" should do what you describe.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#129363 - 2004-11-11 07:36 PM Re: Get the department name from Active Directory.
Anonymous
Unregistered


But I am not looking for the Group Membership. I am looking for Active Directory Users and Computers -> Username -> Properties -> Organization Tab -> Department.

Sorry about the KiXtart mispelling.

-Craig

Top
#129364 - 2004-11-11 07:43 PM Re: Get the department name from Active Directory.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Then why didn't you say so.

That would be a simple bit of ASDI is is done in the UDF,
GetAllADUserInfoToFile() Queries the AD for all user information and writes to file
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#129365 - 2004-11-11 08:07 PM Re: Get the department name from Active Directory.
Anonymous
Unregistered


Ok, I apologize, I didn't think I needed to get into what I was doing to answer this.

Since I am having problems with my user profiles mapping hidden directories I figured I would map them in my logon script which is KiXtart. The main problem is that all my user directories are organized on my File Server First by the Department the work in and then by their username. I could create an IF statement for each user but that would take forever considering I have quite a few users. So I figured I could just set the Department entry in a users properties to their Department then use something like this

USE U: "\\server\userdirs$\$department\$username"
(userdirs$ is the hidden share for my user directorys)

to map the user drive. But I cannot for the life of me figure out how to set $department. I have tried

$username = @USERID
$objUser = GetObject("LDAP://$username")
$department = objUser.Department

but that isn't working. What am I doing wrong here?

Thanks

Again, I apologize if my question was worded to vaguly.

-Al

Top
#129366 - 2004-11-11 08:08 PM Re: Get the department name from Active Directory.
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Chris S. posted this a while back as well. Seems to work well to retrieve the dept of the user thats loggin in.

Code:

$username = @USERID
$objADSystemInfo = CreateObject("ADSystemInfo")
$user = GetObject("LDAP://" + $objADSystemInfo.UserName)
$dept = $user.Department

USE U: "\\server\userdirs$$\"+$dept+"\"+$username



edited since you showed more of what you were doing


Edited by CitrixMan (2004-11-11 08:12 PM)

Top
#129367 - 2004-11-11 08:28 PM Re: Get the department name from Active Directory.
Anonymous
Unregistered


You are the king man!!!

-Al

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1452 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.059 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org