我现在在做AD项目,在修改用户信息时遇到一个问题,当name,和 sAMAccountName 都要修改时根据什么来修改(需要一个唯一的字段),虽然里面有很多唯一的字段,如:uSNCreated,objectSid,objectGUID ,但是它们都是什么大整数/间隔,八进制字符串,取出来的是什么byte数组,System._Comobject ,这种类型的不好操作,
public static bool UpdataAccountByUsername(ADInfo adInfo)
{
DirectoryEntry entry = ADHelper.GetDirectoryObject();
DirectorySearcher mySearcher = new DirectorySearcher(entry)
{
Filter = string.Format("(&(objectClass=user)(objectSid={0}))", adInfo.objectSid)// 这样做不成功,adInfo.objectSid类型为byte数组,取出来是十进制byte数组
};
try
{
SearchResult resEnt = mySearcher.FindOne();
DirectoryEntry de = resEnt.GetDirectoryEntry();
if (adInfo.company != null && adInfo.company != "")
de.Properties["company"].Value = adInfo.company;
if (adInfo.department != null && adInfo.department != "")
de.Properties["department"].Value = adInfo.department;
if (adInfo.departmentNumber != null&& adInfo.departmentNumber != "")
de.Properties["departmentNumber"].Value = adInfo.departmentNumber;
if (adInfo.initials != null&& adInfo.initials != "")
....
请问有什么好的方法吗