Page 1 of 1 1
Topic Options
#146485 - 2005-08-26 08:05 PM Newbie Question (Write AD Object)
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Well... I hope I can fully explain what I want to do.

I am getting ready to deploy a LCS (Live Communication Server) and want to add a SIP address to all my user objects in the AD Domain.

From some previous posts, I have found how to read the objects details, specifically the SIP address of a User.

Code:

$objSystemInfo = CreateObject("ADSystemInfo")
$strAuthDistinguishedName = "LDAP://" + $objSystemInfo.UserName
$UserObj = GetObject($strAuthDistinguishedName)


? "LCS SIP IM Address: " + $UserObj.Get("msRTCSIP-PrimaryUserAddress")
Sleep 10



However, I was wondering if it's even possible to WRITE the address if it's blank?

Any thoughts, comments would be great.

Thanks,
Chris

Top
#146486 - 2005-08-26 08:43 PM Re: Newbie Question (Write AD Object)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I have not tried but cannot see why not. What have you tried? You may need to use the PutEX method.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#146487 - 2005-08-26 08:47 PM Re: Newbie Question (Write AD Object)
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Les, don't mean to be a pain, but could you give me an example? I am totally new to this type of commands.

Chris

Top
#146488 - 2005-08-26 08:52 PM Re: Newbie Question (Write AD Object)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
See Trouble setting a value to nothing ?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#146489 - 2005-08-26 09:06 PM Re: Newbie Question (Write AD Object)
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Dude... you freaking ROCK.

Code:

$UserObj.Put ("msRTCSIP-PrimaryUserAddress","address@@here.com")
$UserObj.setinfo


Top
#146490 - 2005-08-26 09:24 PM Re: Newbie Question (Write AD Object)
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11606
Loc: CA
Knowing what to actually search for in this case is difficult if you don't know any correct keywords to use as CLEAR/DELETE/BLANK/ADSI are not very helpful keywords for this.

Here are some links from a couple years ago where it came up.

http://www.kixtart.org/ubbthreads/showth...page=0&vc=1

http://www.kixtart.org/ubbthreads/showth...page=0&vc=1

Modifying Attributes with ADSI


ADS_PROPERTY_OPERATION_ENUM

Top
#146491 - 2005-08-26 10:16 PM Re: Newbie Question (Write AD Object)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

However, I was wondering if it's even possible to WRITE the address if it's blank?



I misconstrued. I thought you wanted to write a blank (nothing) address!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#146492 - 2005-08-26 11:21 PM Re: Newbie Question (Write AD Object)
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Thanks for the help guys...

Now I have one more question to kind of go along with this one. Is there a way to enumerate all of my users in a certain OU and add a value to their account?

Chris

Top
#146493 - 2005-08-27 01:43 AM Re: Newbie Question (Write AD Object)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Yes.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#146494 - 2005-08-27 01:49 AM Re: Newbie Question (Write AD Object)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I suppose you want another example.
Code:
BREAK ON

$users = GetObject("LDAP://ou=Users,ou=bla,ou=yada,dc=company,dc=local")
$Users.filter = Split('user')

for each $user in $users
if $user.scriptpath <> ""
$loginscript="bla\"+ $user.scriptpath
if $user.scriptpath <> "$loginscript"
;$user.scriptpath = $loginscript
;$user.SetInfo
endif
endif
next

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#146495 - 2005-08-29 08:33 PM Re: Newbie Question (Write AD Object)
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Thank you for the example... However it isn't working. This is the code that I am using. It'll say it changes it, but when I view it in AD, it's still blank.

Code:

$UserObj = GetObject("LDAP://ou=Employees,ou=Users,ou=Location,dc=Company,dc=com")
$UserObj.Filter = Split('user')

For Each $User in $UserObj
$Address = Lcase($User.sAMAccountName) + "@@mycompany.com"
? 'Current address is: ' + $User.Get("mail")
$User.put("mail",$Address)
$User.setinfo
? 'E-mail address is now set to: ' + $User.Get("mail")
Next

Sleep 10



Do I have to run it with elevated permissions?

HELP!!!!

Top
#146496 - 2005-08-29 09:03 PM Re: Newbie Question (Write AD Object)
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11606
Loc: CA
Quote:

Do I have to run it with elevated permissions?





Yes, unless you've modified the AD rights (not recommended) normal users can not modify these settings.

Top
#146497 - 2005-08-29 10:04 PM Re: Newbie Question (Write AD Object)
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Thanks for the response... Tried it with a "Domain Admin" level account and worked fine. I can change my account info, but not anyone elses.

Thanks!

Top
#146498 - 2005-08-29 10:09 PM Re: Newbie Question (Write AD Object)
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11606
Loc: CA
Sure you can, but you need to supply THEIR name, not yours.
Top
#146499 - 2005-08-29 10:42 PM Re: Newbie Question (Write AD Object)
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
I guess, I should clarify. Without using the "Domain Admin" level account, I could only modify my ".mail" setting. However using the code above when logged in with the elivated privileges, everything worked fine. I was able to change 195 accounts in like 5 seconds. Much, much easier.

But again, thanks for the help.

On to the next thread.

Top
#146500 - 2005-08-30 05:31 AM Re: Newbie Question (Write AD Object)
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Might be time to learn a little bit about Windows security. You sound surprised that you need admin-level privileges to make changes to AD.
_________________________
There are two types of vessels, submarines and targets.

Top
#146501 - 2005-08-30 07:47 AM Re: Newbie Question (Write AD Object)
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Actually some of code, showed that the changes were made, but when I viewed the object in ADUC it contradicted the output from the code, I was just confused. But overall I do feel I have a good understanding, just new to this type of "development".

Thanks again for the help guys.
Chris

Top
#146502 - 2006-02-13 09:43 PM Re: Newbie Question (Write AD Object)
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I love Search...

I just had to clear the logonscript value for several OUs of users...

Code:

break on

$OU = 'LDAP://domain/OU=Users, OU=aXX, DC=domain,DC=com'

For each $Item in GetObject($OU)
$cn = $Item.distinguishedName
$UP = GetObject("LDAP://"+$cn)

? $uP.FirstName +' '+ $uP.LastName +' '+$uP.scriptPath

if instr($uP.scriptPath,'smsls')
' changing'
$up.PutEx(1, "ScriptPath", "")
$up.setinfo
endif
$UP = 0
NEXT

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#146503 - 2006-02-14 12:22 AM Re: Newbie Question (Write AD Object)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... since you are showing me yours, I'll show you mine.
This was used to modify the current ScriptPath to reflect the OU medelled folder structure.
Code:

BREAK ON

$users = GetObject("LDAP://ou=Users,ou=FW,ou=yada,dc=bla,dc=local")
$Users.filter = Split('user')

for each $user in $users
if $user.scriptpath <> ""
$loginscript="FW\"+ $user.scriptpath
if $user.scriptpath <> $loginscript
? "Current Script for " +$user.name " is: " +$user.scriptpath+ " Modified to " +$loginscript
;$user.scriptpath = $loginscript
;$user.SetInfo
endif
endif
next

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 139 anonymous users online.
Newest Members
vertage, dimi575, Drecksnacken, Nlill, webtools321
17735 Registered Users

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

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