Re: Some or all identity references could not be translated.



Hi Joe,

I will try to explain better.

First I create OU then inside that OU I create otheres OUs, users and groups.
But sometimes I get error "There is no such object on the server", like there is no OU which I just created.
To create users and groups I use "System.DirectoryServices.AccountManagement" class.
http://msdn.microsoft.com/en-us/library/bb348316.aspx

Dim ctx As New PrincipalContext(ContextType.Domain, strDNSADDomain, strOU)
Dim user As New UserPrincipal(ctx)

strOU = DN - name of newly created OU in which I want to create user

strDNSADDomain = I set empty string, domain name or full DNS DC name
If I set empty string or domain name the error occurs often.
But if I set full DNS DC name the error occurs from time to time when I start to use application, then I just enter DNS name of second DC and code start to work.

If I put some sleep(20-30sec) in code the application work but I think that there is some better way.

hmm...

I think I know where is the problem.

Problem is in creation of OU.
When I create OU I don't bind to specific DC but for path enter "LDAP://OU=name,DC=domain,DC=loc";
Maybe if I enter "LDAP://DC1.domain.name:389/OU=name,DC=domain,DC=loc";

But is this good approach, what if this DC stop to work?

Can you suggest what is the good way to create OU and user inside newly created OU and to avoid problem with AD replication?
Is there some trick like with SID/user name?

Thank you for your help.

--
"Darko Bazulj" <darko.bazulj@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:15AB08F9-9201-4925-BE5A-4AE0AB5B7888@xxxxxxxxxxxxxxxx
Hi Joe,

it works now :))
Thank you for help.

Can you suggest me something about AD.

what I do:

create OU and then create user.
But I sometimes recive error, like there is no OU which I just created but OU is there

strDNSADDomain=
I was put just domain(domain.loc) but I then recived error frequently.
Then I put full DC name(ad1.domain.loc) but mistakes were reduce but nevertheless knows happen.

Can you suggest something??


Code:
----------

create user:

Dim ctx As New PrincipalContext(ContextType.Domain, strDNSADDomain, strOU)

Dim user As New UserPrincipal(ctx)

user.SamAccountName = strSamAccountName
If Not String.IsNullOrEmpty(strDescription) Then user.Description = strDescription
user.SetPassword(strPassword)
user.Enabled = True
user.PasswordNeverExpires = True

If Not String.IsNullOrEmpty(strUPN) Then user.UserPrincipalName = strUPN

user.Save()

user.Dispose()
ctx.Dispose()

create OU:

Dim objAD As DirectoryEntry
Dim objOU As DirectoryEntry

strOU = "OU=" + strOU

objAD = New DirectoryEntry(strPath)

objOU = objAD.Children.Add(strOU, "OrganizationalUnit")
If Not String.IsNullOrEmpty(strDescription) Then objOU.Properties("description").Add(strDescription)
If Not String.IsNullOrEmpty(struPNSuffix) Then objOU.Properties("uPNSuffixes").Add(struPNSuffix)
objOU.CommitChanges()

objOU.Dispose()
objAD.Dispose()

Error:
-------

There is no such object on the server. -- at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit() at System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit() at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize() at System.DirectoryServices.AccountManagement.PrincipalContext.ContextForType(Type t) at System.DirectoryServices.AccountManagement.Principal.GetStoreCtxToUse() at System.DirectoryServices.AccountManagement.Principal.set_SamAccountName(String value) at serviceprovisioning.ActiveDirectory.CreateUser(String strSamAccountName, String strPassword, String strOU, String strDescription, String strUPN, String strDNSADDomain)


.



Relevant Pages

  • Re: Some or all identity references could not be translated.
    ... Dim ctx As New PrincipalContext(ContextType.Domain, strDNSADDomain, strOU) ... Dim user As New UserPrincipal ... If I set empty string or domain name the error occurs often. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Search pattern
    ... Dim strfile As String ... Dim bAddressFound As Boolean ... Dim strCurrentChar As String ...
    (comp.databases.ms-access)
  • Auto Write Name and Merge across
    ... Dim Sheetname01 As String ... Dim WeekName01 As String ...
    (microsoft.public.excel.misc)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)