ntaccaunt.translate and AD

Discussion in 'ASP .Net Security' started by Darko Bazulj, Jul 9, 2008.

  1. Darko Bazulj

    Darko Bazulj Guest

    Hi,

    problem:

    when I create user or group I want to set permissions on OU for that user or
    group.
    But I'm getting error if I don't put some sleep 20-30 sec.

    Like user or group doesn't exist and I can't do translate.
    Like there is some problem with replication of data and I need to bind to DC
    on which I created user or group and do translate.
    But I don't know how.

    Can someone help or suggest something??

    ERROR :

    Some or all identity references could not be translated. -- at
    System.Security.Principal.NTAccount.Translate(IdentityReferenceCollection
    sourceAccounts, Type targetType, Boolean forceSuccess) at
    System.Security.Principal.NTAccount.Translate(Type targetType) at
    serviceprovisioning.ActiveDirectory.NTaccountToSID(String strNTaccountName,
    String strADDomain) in C:\Users\darko\Documents\Visual Studio
    2008\Projects\serviceprovisioning\serviceprovisioning\functions\ActiveDirectory.vb:line
    237


    CODE :

    Function NTaccountToSID(ByVal strNTaccountName As String, ByVal strADDomain
    As String) As SecurityIdentifier

    Dim identity As New NTAccount(strADDomain, strNTaccountName)

    line 237 --> Dim SID As SecurityIdentifier =
    DirectCast(identity.Translate(GetType(SecurityIdentifier)),
    SecurityIdentifier)

    Return SID

    End Function
    Darko Bazulj, Jul 9, 2008
    #1
    1. Advertising

  2. Darko Bazulj

    Darko Bazulj Guest

    Hi,

    problem solved.

    Now I can bind to DC on which I created user/group and set permissions on OU
    without errors.

    Here is the code, maybe help someone.

    Function GetADObjectSID(ByVal strObjectDNname As String)

    Dim DirEntry As DirectoryServices.DirectoryEntry = New
    DirectoryServices.DirectoryEntry(strObjectDNname)
    Dim objSid() As Byte = CType(DirEntry.Properties("objectSid").Value,
    Byte())
    Dim SID As New System.Security.Principal.SecurityIdentifier(objSid,
    0)

    Return SID

    End Function
    Darko Bazulj, Jul 9, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sridhar Hegde
    Replies:
    2
    Views:
    2,512
    Ajeetha Kumari
    Sep 13, 2004
  2. Jeff Epler
    Replies:
    1
    Views:
    307
    =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=
    Sep 18, 2003
  3. Raaijmakers, Vincent (IndSys, GE Interlogix)

    RE: needs help in how to translate ≴ and ≵

    Raaijmakers, Vincent (IndSys, GE Interlogix), Sep 18, 2003, in forum: Python
    Replies:
    1
    Views:
    371
    Erik Max Francis
    Sep 18, 2003
  4. orch
    Replies:
    0
    Views:
    822
  5. Guest
    Replies:
    2
    Views:
    339
    Guest
    Aug 17, 2007
Loading...

Share This Page