public static Guid GetGuid(this LdapEntry entry)
{
try
{
LdapAttribute guidAttr = entry.getAttribute("GUID");
if (guidAttr != null && guidAttr.StringValue.Length != 0)
{
byte[] bGuid = new byte[8];
for (int i = 0; i < 8; i++)
{
bGuid[i] = (byte)guidAttr.ByteValue[i];
}
Guid guid = new Guid(
BitConverter.ToInt32(bGuid, 0),
BitConverter.ToInt16(bGuid, 4),
BitConverter.ToInt16(bGuid, 6),
(byte)guidAttr.ByteValue[8],
(byte)guidAttr.ByteValue[9],
(byte)guidAttr.ByteValue[10],
(byte)guidAttr.ByteValue[11],
(byte)guidAttr.ByteValue[12],
(byte)guidAttr.ByteValue[13],
(byte)guidAttr.ByteValue[14],
(byte)guidAttr.ByteValue[15]);
return guid;
}
else
{
App.Log.Error(App.AppResources.Strings.FormatString("NovellDirectoryAttributeReadFailed", "Guid", entry.DN));
App.Log.Trace("Exception in NovellDirectoryProvider: Error in reading Guid attribute for {0}", entry.DN);
throw new DirectoryException(DirectoryErrorCodes.MandatoryAttributeReadFailed, App.AppResources.Strings.FormatString("NovellDirectoryAttributeReadFailed", "Guid", entry.DN));
}
}
catch (LdapException x)
{
}
catch (Exception x)
{}
} |