Page 1 of 3 123>
Topic Options
#141640 - 2005-06-15 02:50 PM Please help
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
I posted this in the UDF forum as well because I am not sure if what I am asking for is a UDF for script. I have a need to capture the user's department or office information. Before when I asked about this we were trying to use GetUserOU UDF and it was becoming very hard to break apart the deparment name. So I am going to manually make the department names correct in AD in either the "Office" on the General Tab or the "Department" on the Organization tab. I want to be able to pull this information I enter so I can dump it into a database. All I need is the proper AD query info.
Top
#141641 - 2005-06-15 03:24 PM Re: Please help
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
WIth 162 posts under your belt, I would have thought that you would know what our posting rules of conduct are by now. Please review the guidlines and follow them.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#141642 - 2005-06-15 03:28 PM Re: Please help
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
Good grief, your going to nickle and dime me for that? What I am posting can only help people it isn't like I am abusing or anything.
Top
#141643 - 2005-06-15 03:38 PM Re: Please help
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
I apologize for cross-posting but I was unsure which forum my question would be related to. My first guess is UDF's but who knows someone could have a script that does it.
Top
#141644 - 2005-06-15 04:42 PM Re: Please help
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
Desperately need to figure this out so I can deploy it this afternoon! Anyone -please please please please......
Top
#141645 - 2005-06-15 04:57 PM Re: Please help
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Can't test now cause no AD available at home.
This could get you started.
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB13&Number=133801

Quote:


Code:

$GroupObj=GetObject("WinNT://"+ @ldomain + "/Domain Users")
For Each $UserObj in $GroupObj.Members
?$UserObj.Name
?$UserObj.FullName
Next







As far as I can see just change the name or fullname to the field you require.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#141646 - 2005-06-15 05:03 PM Re: Please help
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
DJ:

Just did a little test on a local group with the code above and works fine. So it should deliver the required info in your case also.

[edit]
Credits go to Kent. See link above.
[/edit]


Edited by Mart (2005-06-15 05:04 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#141647 - 2005-06-15 05:03 PM Re: Please help
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
Nah that didn't work - it is a start but I am not sure which AD attribute is for "Office". According to MSDN it is physicalDeliveryOfficeName
but not quite sure how to incorporate that.

Top
#141648 - 2005-06-15 05:06 PM Re: Please help
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Hold on....will vpn to the office and do a little test there.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#141649 - 2005-06-15 05:07 PM Re: Please help
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
I don't want to retrieve name - I can already do that. The only thing I want to retrieve "Office" on the General tab. Your code you posted does work for Full Name - but I try that physicalDeliveryOfficeName and really doesn't do anything. I know it is wrong but was hoping someone else is already doing this.
Top
#141650 - 2005-06-15 05:12 PM Re: Please help
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
I know the fields you are trying to get. Testing now so hold your horses.
The name and fullname is just an example.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#141651 - 2005-06-15 05:16 PM Re: Please help
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA


http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB1&Number=133341

http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB13&Number=126607

http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB12&Number=83054
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#141652 - 2005-06-15 05:29 PM Re: Please help
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
WinNT:// will not be able to expose this information, you have to use LDAP://

to construct the ldap path to a user bob, who is located in...

Code:

domina.local
CompanyA
Corporate Office
<Bill smith>





Code:

$user = GetObject("LDAP://CN=Bill Smith,OU=Corporate office,OU=CompanyA,DC=domain,DC=local")
? $user.OfficeLocations


Top
#141653 - 2005-06-15 05:30 PM Re: Please help
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
Sorry Mart - I am just trying to make sense of it. I have a list of like every ADSI object and don't really know how to put that into kix terms.
Top
#141654 - 2005-06-15 05:33 PM Re: Please help
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
I have a fairly complex AD structure for various multiple remote locations and departments. That is why I had trouble before trying to use the GetUserOU UDF to achieve a similar thing. The TranslateName would be too complicated because of my AD structure. I figured if I manually entered the Office Names and then I could just pull that one field from the user's ad profile.
Top
#141655 - 2005-06-15 05:56 PM Re: Please help
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
OK just did a little test with Bryce's code and this will show the details you need.
Hehe learned something today. Do not use this com stuff all that much (forgot to start from the back when filling the OU fields ) so its a little rusty.

It shows whatever I put in the users office field in AD.
Fieldnames seem to be different then when using WinNT or LDAP so a LDAP browser would be nice


Edited by Mart (2005-06-15 05:58 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#141656 - 2005-06-15 06:46 PM Re: Please help
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Here is an example of retrieving this information using fnLDAPQuery()...

Code:

Call "fnLDAPQuery.kix"

$=SetOption("WrapAtEOL","on")
$=SetOption("NoVarsInStrings","on")
;$=SetOption("Explicit","on")

Dim $sWhat,$sFrom,$sFilter,$sScope,$aResults,$Result,$R,$

$sWhat = "ADsPath","Name","department","physicalDeliveryOfficeName"

$sFrom = "LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")

$sFilter = "(&(objectCategory=user)(Name=sh*))"

$sScope = "subtree"

$aResults = fnLDAPQuery($sWhat,$sFrom,$sFilter,"displayName ASC",$sScope)
@ERROR " : " @SERROR ?

For Each $Result in $aResults
If VarType($Result)>8192
For Each $R in $Result
$R ?
Next
Else
$Result ?
EndIf
Next


Top
#141657 - 2005-06-15 06:55 PM Re: Please help
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
Ok with Bryce's code though that is displaying or would be displaying a specific user. See what is going to happen is this. Our default logon script runs. Then just before it exits it is going to call this pc inventory script to retrieve this information and dump it into an SQL database. It all works except retrieving the office they are located in. So i will need it to pull the office that the current user logging on is in.
Top
#141658 - 2005-06-15 06:57 PM Re: Please help
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
Chris your code errors out on line 22. Expected expression error.
Top
#141659 - 2005-06-15 06:59 PM Re: Please help
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
You need to include fnLDAPQuery() in the script. Use the last one posted in the link.
Top
Page 1 of 3 123>


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

Who's Online
0 registered and 484 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.138 seconds in which 0.082 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