![]() |
|
|
|
|
1
30th October 05:51
External User
Posts: 1
|
I have a folder full of employee pictures.
The name format is from active directory, as "sn, givenname.JPG" Now I have a web app that can not access the first and last name to display the picture. It only knows the SAMAccountName. Does anyone have a clue where to start with a script to copy these files from "sn, givenname.JPG" to "SAMAccountName.jpg" ?? -- -- Steven http://www.glimasoutheast.org |
|
|
|
|
2
30th October 05:51
External User
Posts: 1
|
The only solution I can think of is a script that reads the file name and
parses the values of the sn and givenName attributes, then uses ADO to search Active Directory for the user object that has these values. You would return the value of sAMAccountName. For information on using ADO for this, see this link: http://www.rlmueller.net/ADOSearchTips.htm The problem is that you may find no users, one user, or several users that match your query. Many users could have the same first and last names (assuming these fields are filled in, as they are not required). In brief, the query would be (using syntax similar to what I use in the link above): ' You would parse the file name for these values. strFirst = "Jim" strLast = "Smith" Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") strBase = "<LDAP://" & strDNSDomain & ">" strFilter = "(&(objectCategory=person)(objectClass=user)(given Name=" _ & strFirst & ")(sn=" & strLast & "))" strAttributes = "sAMAccountName,cn" strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree" The code should account for the 3 possibilities: there is one record in the resulting recordset, no records, or more than one. Richard Mueller (MVP) |
|