Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Unable to get SID using AD Call in Custom Security

Author  Topic 

chiranjivchoudhary
Starting Member

1 Post

Posted - 2009-04-03 : 00:53:56
Hi,
I have implemented Custom Security Extension to my Reports project. I am implementing it in ssrs 2005 32bit & 64 bit. All is working well except on 64 bit. I want that any user who has logged using Windows authentication should be able to call DirectoryEntry(...) class's property to get "objectSID".
Following is the code :-

private static string GetSid(string loginUser)
{
string userSID = "";
try
{
// Parse the string to check if domain name is present.
int idx = loginUser.IndexOf('\\');
if (idx == -1)
{
idx = loginUser.IndexOf('@');
}

string userDomain;
string userName;

if (idx != -1)
{
userDomain = loginUser.Substring(0, idx);
userName = loginUser.Substring(idx + 1);
}
else
{
return userSID;
}

DirectoryEntry obDirEntry = null;

obDirEntry = new DirectoryEntry("WinNT://" + userDomain + "/" + userName);

System.DirectoryServices.PropertyCollection coll = obDirEntry.Properties;

object obVal = coll["objectSid"].Value;


if (null != obVal)
{
userSID = ConvertByteToStringSid((Byte[])obVal);
}
}
catch (Exception ex)
{
userSID = "";
}

return userSID;
}


Following is the error :-

System.Runtime.Interopservices.COMException (0x80005000): Unknown error (0x80005000)| at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)| at System.DirectoryServices.DirectoryEntry.Bind()| at System.DirectoryServices.DirectoryEntry.get_AdsObject()| at System.DirectoryServices.PropertyValueCollection.PopulateList()| at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)| at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)|


CODE is not in RDL related CS file but in Custome Security Extension related class.

Any help will be highly appreciated.
   

- Advertisement -