Add X500 for a user


Add X500 for a user
I want help with adding X500 to all users in a txt file
Can anyone help.

LVL 11
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bsharathAuthor Commented:
I will have the txt file as
Samaccount name;/o=Group/ou=First Administrative Group/cn=Recipients/cn=Samaccountname
Samaccount i mean as Ntlogin
are you looking to add the x500 address to a matching sAMAccountName  in Active Directory (in the proxyAddresses attribute)?
bsharathAuthor Commented:
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bsharathAuthor Commented:
Thanks Mark its perfect
One question with the script
This line
x500Base = "/o=ExampleAB/ou=Organizationalunit1/cn=Recipients/cn="
Will the script run on every user and add like this
x500Base = "/o=ExampleAB/ou=Organizationalunit1/cn=Recipients/cn=Samaccount"
Yes it will.
bsharathAuthor Commented:
as you stated some may faile if renamed. how can i find which failed
I have few users Samaccount that i have renamed those may fail i guess
you would need to query against sAMAccountName and compare that to the email address.  How many users are we talking about there?  You could probably grab that info quickly with a custom AD Query in ADUC and just quickly scan the results by eye.  Or dump into Excel and use a formula to compare the two columns.
bsharathAuthor Commented:
Samaccounts in mine will look as

I have totally 5000+ users
This is untested but hopefully will give you a list of the accounts that will be in trouble.
On Error Resume Next

Dim qQuery, objConnection, objCommand, objRecordSet, obj
Dim oRootDSE, strDomain

Set oRootDSE = GetObject("LDAP://rootDSE")
strDomain = oRootDSE.get("defaultNamingContext")

' other categories = computer, user, printqueue, group
qQuery = "<LDAP://" & strDomain &">;" & _
		"(objectCategory=person)" & _

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 999 
objCommand.CommandText = qQuery
Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF
	If objRecordSet.Fields("sAMAccountName") & "" <> objRecordSet.Fields("mailNickname") Then
    	report = report & objRecordSet.Fields("sAMAccountName") & " is different from " & objRecordSet.Fields("mailNickname") & vbCrLf
    End If


WScript.Echo report

Open in new window

bsharathAuthor Commented:
I get all the usrs listed even though they are correct
Sorry I don't have a test environment that I can use for this at the moment.  If they are just one off instances then why not wait for someone to yell and fix them?  
bsharathAuthor Commented:
Thanks Mark...
I guess will do it on all and wait for some one who might have a mail bounce thank U
What is the time out there for you.?
Can you have a look at this please... Vbs is also fine on this
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.