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



I didn't quite follow what you were saying here. You do need to make sure
you are working off of the same server though. Could that be the problem?
Please try to explain again.

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"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)


----------------------------------------------
#example if someone else have similar problems.

Dim identity As NTAccount

identity = New NTAccount(strUserName)

Dim sid As SecurityIdentifier =
DirectCast(identity.Translate(GetType(SecurityIdentifier)),
SecurityIdentifier)

Dim dInfo As New DirectoryInfo(strFolderName)
Dim dSecurity As DirectorySecurity =
dInfo.GetAccessControl(AccessControlSections.Access)

dSecurity.AddAccessRule(New FileSystemAccessRule(sid, _
rights, _
iFlags, _
pFlags, _
acType))

dInfo.SetAccessControl(dSecurity)





.



Relevant Pages

  • Re: Need Help | Rolling out new App. | Trouble with some computers
    ... Server as the back end. ... Option Compare Database ... Dim varReturn As Variant ... Dim lngAuth As Long, strDept As String, strFirst As String, strLast ...
    (microsoft.public.access.modulesdaovba)
  • Re: strange problem with smtpmail
    ... Note that remote server is a BLS server but a windows ... e-mails are send but arrive as HTML source instead of formatted HTML ... Public Function SendMailMessage(ByVal Recipient As String, ... Dim mMailMessage As New MailMessage ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Desperately need help to setup with asp net !!
    ... must be done by the Vb.net application on the server. ... What I have hard time to implement is passing data from the browser to ... Dim strConnection As String ... Dim con As New Data.SqlClient.SqlConnection ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Best way to communicate from Desktop to SQL DB
    ... the remote SQL Server, in other words, how do I create a connection string ... to a remote server. ... Dim cmd As New SqlCommand ... Dim ProductID As Integer = CType, ...
    (microsoft.public.dotnet.languages.vb)
  • Using Visual Basic NET to Access Terminal Services Session and Client Information
    ... It also accesses the Client Information for the client which executes this program on a Terminal Services Server. ... Dim pWinStationName As String ' integer LPTSTR - Pointer to a null-terminated string containing the name of the WinStation for this session ...
    (microsoft.public.windows.terminal_services)