现在的位置: 首页 > 综合 > 正文

Active Directory objectsid to string

2012年05月18日 ⁄ 综合 ⁄ 共 374字 ⁄ 字号 评论关闭

通过LDAP查找出来的结果的Properties中经常会包含byte[]类型的SId,并不是我们在AD中看到的s-x-x-形式的。通过以下函数将其转换。

 

 1 /// <summary>
 2 /// 转换Byte Sid to string
 3 /// </summary>
 4 /// <param name="sidBinary"></param>
 5 /// <returns></returns>
 6 public static string ConvertBinarySid2String(byte[] sidBinary)
 7 {
 8     SecurityIdentifier sid = new SecurityIdentifier(sidBinary, 0);
 9     return sid.ToString();
10 }

 

抱歉!评论已关闭.