Computername Web Service, AD Description?

May 27, 2011 at 4:35 PM

Hi

I followed Maiks guide at http://myitforum.com/cs2/blogs/maikkoster/archive/2011/04/04/michael-niehaus-ris-style-naming-web-service-step-by-step.aspx and got it working. I see that the Computers are added to AD with Computer Description "Added by MDT". I can see in the code that it is showing:

DirectoryEntry dirEntry = new DirectoryEntry("LDAP://" + machineObjectOU);

DirectoryEntry newUser = dirEntry.Children.Add("CN=" + nextName, "computer");

newUser.Properties["samAccountName"].Value = nextName + "$";               

newUser.Properties["netbootGUID"].Value = existingUuid.ToByteArray();               

newUser.Properties["description"].Value = "Added by MDT";               

newUser.Properties["userAccountControl"].Value = 4128;

 

Because I'm don't know how to code and also not that good with IIS I just followed and copy pasted as it said in the blogpost. How can I change the description to build date or Computer model or anything else?

 

/A

 

 

 

Jun 6, 2011 at 8:36 PM

You can just tweak the line

newUser.Properties("description").Value = "Added by MDT"

into whatever you would like to have in your description. If you want to include some information from the local computer, it might be the best idea to add a new parameter to that function to supply the Description and just use whatevery is being supplied by the computer. You can then assemble the necessary information on the calling computer.

Regards

Maik